!103 [Sync] Sync patch from openeuler/gcc
From: @eastb233 Reviewed-by: @haijianzhang Signed-off-by: @haijianzhang
This commit is contained in:
commit
1f9b0a1815
5966
0014-Backport-StructReorg-Structure-reorganization-optimi.patch
Normal file
5966
0014-Backport-StructReorg-Structure-reorganization-optimi.patch
Normal file
File diff suppressed because it is too large
Load Diff
2134
0015-CompleteStructReorg-Complete-Structure-Reorganizatio.patch
Normal file
2134
0015-CompleteStructReorg-Complete-Structure-Reorganizatio.patch
Normal file
File diff suppressed because it is too large
Load Diff
486
0016-StructReorg-Bugfix-in-certain-scenarios.patch
Normal file
486
0016-StructReorg-Bugfix-in-certain-scenarios.patch
Normal file
@ -0,0 +1,486 @@
|
|||||||
|
From 2194d59a20be1ab627089d2f0c082b5a0a217f52 Mon Sep 17 00:00:00 2001
|
||||||
|
From: xiezhiheng <xiezhiheng@huawei.com>
|
||||||
|
Date: Tue, 3 Aug 2021 03:49:52 -0400
|
||||||
|
Subject: [PATCH 16/22] [StructReorg] Bugfix in certain scenarios
|
||||||
|
|
||||||
|
Some bugfix in certain scenarios,
|
||||||
|
1. disable type simplify in LTO within optimizations
|
||||||
|
2. only enable optimizations in C language
|
||||||
|
3. use new to initialize allocated memory in symbol-summary.h
|
||||||
|
4. cover escape scenarios not considered
|
||||||
|
|
||||||
|
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
index 5a19ea0bb40..1cb544ec3b0 100644
|
||||||
|
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
@@ -97,6 +97,7 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
#include "tree-eh.h"
|
||||||
|
#include "bitmap.h"
|
||||||
|
#include "cfgloop.h"
|
||||||
|
+#include "langhooks.h"
|
||||||
|
#include "ipa-param-manipulation.h"
|
||||||
|
#include "tree-ssa-live.h" /* For remove_unused_locals. */
|
||||||
|
|
||||||
|
@@ -161,6 +162,44 @@ handled_type (tree type)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Check whether in C language or LTO with only C language. */
|
||||||
|
+bool
|
||||||
|
+lang_c_p (void)
|
||||||
|
+{
|
||||||
|
+ const char *language_string = lang_hooks.name;
|
||||||
|
+
|
||||||
|
+ if (!language_string)
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (strcmp (language_string, "GNU GIMPLE") == 0)
|
||||||
|
+ {
|
||||||
|
+ unsigned i = 0;
|
||||||
|
+ tree t = NULL;
|
||||||
|
+ const char *unit_string = NULL;
|
||||||
|
+
|
||||||
|
+ FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, t)
|
||||||
|
+ {
|
||||||
|
+ unit_string = TRANSLATION_UNIT_LANGUAGE (t);
|
||||||
|
+ if (!unit_string
|
||||||
|
+ || (strncmp (unit_string, "GNU C", 5) != 0)
|
||||||
|
+ || (!ISDIGIT (unit_string[5])))
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ else if (strncmp (language_string, "GNU C", 5) == 0
|
||||||
|
+ && ISDIGIT (language_string[5]))
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
enum srmode
|
||||||
|
{
|
||||||
|
NORMAL = 0,
|
||||||
|
@@ -999,7 +1038,6 @@ public:
|
||||||
|
void analyze_types (void);
|
||||||
|
void clear_visited (void);
|
||||||
|
bool create_new_types (void);
|
||||||
|
- void restore_field_type (void);
|
||||||
|
void create_new_decls (void);
|
||||||
|
srdecl *find_decl (tree);
|
||||||
|
void create_new_functions (void);
|
||||||
|
@@ -2127,7 +2165,12 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
srtype *t = find_type (inner_type (TREE_TYPE (rhs)));
|
||||||
|
srdecl *d = find_decl (lhs);
|
||||||
|
if (!d && t)
|
||||||
|
- current_function->record_decl (t, lhs, -1);
|
||||||
|
+ {
|
||||||
|
+ current_function->record_decl (t, lhs, -1);
|
||||||
|
+ tree var = SSA_NAME_VAR (lhs);
|
||||||
|
+ if (var && VOID_POINTER_P (TREE_TYPE (var)))
|
||||||
|
+ current_function->record_decl (t, var, -1);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
if (TREE_CODE (rhs) == SSA_NAME
|
||||||
|
&& VOID_POINTER_P (TREE_TYPE (rhs))
|
||||||
|
@@ -2136,7 +2179,12 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
srtype *t = find_type (inner_type (TREE_TYPE (lhs)));
|
||||||
|
srdecl *d = find_decl (rhs);
|
||||||
|
if (!d && t)
|
||||||
|
- current_function->record_decl (t, rhs, -1);
|
||||||
|
+ {
|
||||||
|
+ current_function->record_decl (t, rhs, -1);
|
||||||
|
+ tree var = SSA_NAME_VAR (rhs);
|
||||||
|
+ if (var && VOID_POINTER_P (TREE_TYPE (var)))
|
||||||
|
+ current_function->record_decl (t, var, -1);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
@@ -2816,8 +2864,14 @@ ipa_struct_reorg::maybe_record_call (cgraph_node *node, gcall *stmt)
|
||||||
|
if (escapes != does_not_escape)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < gimple_call_num_args (stmt); i++)
|
||||||
|
- mark_type_as_escape (TREE_TYPE (gimple_call_arg (stmt, i)),
|
||||||
|
- escapes);
|
||||||
|
+ {
|
||||||
|
+ mark_type_as_escape (TREE_TYPE (gimple_call_arg (stmt, i)),
|
||||||
|
+ escapes);
|
||||||
|
+ srdecl *d = current_function->find_decl (
|
||||||
|
+ gimple_call_arg (stmt, i));
|
||||||
|
+ if (d)
|
||||||
|
+ d->type->mark_escape (escapes, stmt);
|
||||||
|
+ }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -3753,49 +3807,6 @@ ipa_struct_reorg::analyze_types (void)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* When struct A has a struct B member, B's type info
|
||||||
|
- is not stored in
|
||||||
|
- TYPE_FIELDS (TREE_TYPE (TYPE_FIELDS (typeA)))
|
||||||
|
- Try to restore B's type information. */
|
||||||
|
-void
|
||||||
|
-ipa_struct_reorg::restore_field_type (void)
|
||||||
|
-{
|
||||||
|
- for (unsigned i = 0; i < types.length (); i++)
|
||||||
|
- {
|
||||||
|
- for (unsigned j = 0; j < types[i]->fields.length (); j++)
|
||||||
|
- {
|
||||||
|
- srfield *field = types[i]->fields[j];
|
||||||
|
- if (TREE_CODE (inner_type (field->fieldtype)) == RECORD_TYPE)
|
||||||
|
- {
|
||||||
|
- /* If field type has TYPE_FIELDS information,
|
||||||
|
- we do not need to do this. */
|
||||||
|
- if (TYPE_FIELDS (field->type->type) != NULL)
|
||||||
|
- {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- for (unsigned k = 0; k < types.length (); k++)
|
||||||
|
- {
|
||||||
|
- if (i == k)
|
||||||
|
- {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- const char *type1 = get_type_name (field->type->type);
|
||||||
|
- const char *type2 = get_type_name (types[k]->type);
|
||||||
|
- if (type1 == NULL || type2 == NULL)
|
||||||
|
- {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- if (type1 == type2
|
||||||
|
- && TYPE_FIELDS (types[k]->type))
|
||||||
|
- {
|
||||||
|
- field->type = types[k];
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
/* Create all new types we want to create. */
|
||||||
|
|
||||||
|
bool
|
||||||
|
@@ -4652,7 +4663,6 @@ ipa_struct_reorg::rewrite_functions (void)
|
||||||
|
{
|
||||||
|
unsigned retval = 0;
|
||||||
|
|
||||||
|
- restore_field_type ();
|
||||||
|
/* Create new types, if we did not create any new types,
|
||||||
|
then don't rewrite any accesses. */
|
||||||
|
if (!create_new_types ())
|
||||||
|
@@ -4887,7 +4897,10 @@ pass_ipa_struct_reorg::gate (function *)
|
||||||
|
&& flag_ipa_struct_reorg
|
||||||
|
/* Don't bother doing anything if the program has errors. */
|
||||||
|
&& !seen_error ()
|
||||||
|
- && flag_lto_partition == LTO_PARTITION_ONE);
|
||||||
|
+ && flag_lto_partition == LTO_PARTITION_ONE
|
||||||
|
+ /* Only enable struct optimizations in C since other
|
||||||
|
+ languages' grammar forbid. */
|
||||||
|
+ && lang_c_p ());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anon namespace
|
||||||
|
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
|
||||||
|
index fa1df5c8015..a223b4dadea 100644
|
||||||
|
--- a/gcc/symbol-summary.h
|
||||||
|
+++ b/gcc/symbol-summary.h
|
||||||
|
@@ -59,6 +59,12 @@ protected:
|
||||||
|
/* Allocates new data that are stored within map. */
|
||||||
|
T* allocate_new ()
|
||||||
|
{
|
||||||
|
+ /* In structure optimizatons, we call new to ensure that
|
||||||
|
+ the allocated memory is initialized to 0. */
|
||||||
|
+ if (flag_ipa_struct_reorg)
|
||||||
|
+ return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T ()
|
||||||
|
+ : new T ();
|
||||||
|
+
|
||||||
|
/* Call gcc_internal_because we do not want to call finalizer for
|
||||||
|
a type T. We call dtor explicitly. */
|
||||||
|
return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T ()
|
||||||
|
@@ -71,7 +77,12 @@ protected:
|
||||||
|
if (is_ggc ())
|
||||||
|
ggc_delete (item);
|
||||||
|
else
|
||||||
|
- m_allocator.remove (item);
|
||||||
|
+ {
|
||||||
|
+ if (flag_ipa_struct_reorg)
|
||||||
|
+ delete item;
|
||||||
|
+ else
|
||||||
|
+ m_allocator.remove (item);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unregister all call-graph hooks. */
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-5.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-5.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..273baa9a368
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-5.c
|
||||||
|
@@ -0,0 +1,31 @@
|
||||||
|
+/* { dg-do compile } */
|
||||||
|
+/* { dg-additional-options "-flto -fno-use-linker-plugin" } */
|
||||||
|
+
|
||||||
|
+struct D
|
||||||
|
+{
|
||||||
|
+ int n;
|
||||||
|
+ int c [8];
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+struct A
|
||||||
|
+{
|
||||||
|
+ int i;
|
||||||
|
+ char *p;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+struct B
|
||||||
|
+{
|
||||||
|
+ struct A *a;
|
||||||
|
+ struct D *d;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+int dtInsert1 (struct B *b)
|
||||||
|
+{
|
||||||
|
+ struct A a = { 0, 0 };
|
||||||
|
+ struct D *d;
|
||||||
|
+ b->a = &a;
|
||||||
|
+ d = b->d;
|
||||||
|
+ &d->c [d->n];
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-6.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-6.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..455f9b501d6
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-6.c
|
||||||
|
@@ -0,0 +1,54 @@
|
||||||
|
+/* { dg-do compile } */
|
||||||
|
+/* { dg-additional-options "-flto -fno-use-linker-plugin" } */
|
||||||
|
+
|
||||||
|
+typedef struct basic_block_def *basic_block;
|
||||||
|
+typedef struct gimple_seq_node_d *gimple_seq_node;
|
||||||
|
+typedef struct gimple_seq_d *gimple_seq;
|
||||||
|
+typedef struct
|
||||||
|
+{
|
||||||
|
+ gimple_seq_node ptr;
|
||||||
|
+ gimple_seq seq;
|
||||||
|
+ basic_block bb;
|
||||||
|
+} gimple_stmt_iterator;
|
||||||
|
+typedef void *gimple;
|
||||||
|
+extern void exit(int);
|
||||||
|
+struct gimple_seq_node_d
|
||||||
|
+{
|
||||||
|
+ gimple stmt;
|
||||||
|
+ struct gimple_seq_node_d *next;
|
||||||
|
+};
|
||||||
|
+struct gimple_seq_d
|
||||||
|
+{
|
||||||
|
+};
|
||||||
|
+static __inline__ gimple_stmt_iterator
|
||||||
|
+gsi_start (gimple_seq seq)
|
||||||
|
+{
|
||||||
|
+ gimple_stmt_iterator i;
|
||||||
|
+ i.seq = seq;
|
||||||
|
+ return i;
|
||||||
|
+}
|
||||||
|
+static __inline__ unsigned char
|
||||||
|
+gsi_end_p (gimple_stmt_iterator i)
|
||||||
|
+{
|
||||||
|
+ return i.ptr == ((void *)0);
|
||||||
|
+}
|
||||||
|
+static __inline__ void
|
||||||
|
+gsi_next (gimple_stmt_iterator *i)
|
||||||
|
+{
|
||||||
|
+ i->ptr = i->ptr->next;
|
||||||
|
+}
|
||||||
|
+static __inline__ gimple
|
||||||
|
+gsi_stmt (gimple_stmt_iterator i)
|
||||||
|
+{
|
||||||
|
+ return i.ptr->stmt;
|
||||||
|
+}
|
||||||
|
+void
|
||||||
|
+c_warn_unused_result (gimple_seq seq)
|
||||||
|
+{
|
||||||
|
+ gimple_stmt_iterator i;
|
||||||
|
+ for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
|
||||||
|
+ {
|
||||||
|
+ gimple g = gsi_stmt (i);
|
||||||
|
+ if (!g) exit(0);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-7.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-7.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..afc0bd86ca5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-7.c
|
||||||
|
@@ -0,0 +1,38 @@
|
||||||
|
+/* { dg-do run } */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+
|
||||||
|
+struct gki_elem {
|
||||||
|
+ char *key;
|
||||||
|
+ int idx;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ struct gki_elem *table;
|
||||||
|
+
|
||||||
|
+ int primelevel;
|
||||||
|
+ int nhash;
|
||||||
|
+ int nkeys;
|
||||||
|
+} GKI;
|
||||||
|
+
|
||||||
|
+void *
|
||||||
|
+sre_malloc(size_t size)
|
||||||
|
+{
|
||||||
|
+ void *ptr = malloc (size);
|
||||||
|
+ return ptr;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+__attribute__((noinline)) int
|
||||||
|
+GKIStoreKey(GKI *hash)
|
||||||
|
+{
|
||||||
|
+ hash->table = sre_malloc(sizeof(struct gki_elem));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+main ()
|
||||||
|
+{
|
||||||
|
+ GKI *hash = malloc (sizeof(GKI));
|
||||||
|
+ GKIStoreKey(hash);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-8.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-8.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..9bcfaf3681b
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-8.c
|
||||||
|
@@ -0,0 +1,25 @@
|
||||||
|
+/* { dg-do run } */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ unsigned char blue;
|
||||||
|
+ unsigned char green;
|
||||||
|
+} Pixel;
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ unsigned short colormaplength;
|
||||||
|
+ Pixel *colormapdata;
|
||||||
|
+} TargaImage;
|
||||||
|
+
|
||||||
|
+TargaImage *img;
|
||||||
|
+
|
||||||
|
+int main() {
|
||||||
|
+ img = (TargaImage *) malloc( sizeof(TargaImage) );
|
||||||
|
+ if (img->colormaplength > 0) {
|
||||||
|
+ img->colormapdata = (Pixel *) malloc(sizeof(Pixel) * img->colormaplength);
|
||||||
|
+ memset(img->colormapdata, 0, (sizeof(Pixel) * img->colormaplength) );
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/struct_reorg-9.c b/gcc/testsuite/gcc.dg/struct/struct_reorg-9.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..052f4e3bdc1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/struct_reorg-9.c
|
||||||
|
@@ -0,0 +1,54 @@
|
||||||
|
+/* { dg-do run } */
|
||||||
|
+
|
||||||
|
+extern void abort(void);
|
||||||
|
+
|
||||||
|
+struct packed_ushort {
|
||||||
|
+ unsigned short ucs;
|
||||||
|
+} __attribute__((packed));
|
||||||
|
+
|
||||||
|
+struct source {
|
||||||
|
+ int pos, length;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int flag;
|
||||||
|
+
|
||||||
|
+static void __attribute__((noinline)) fetch(struct source *p)
|
||||||
|
+{
|
||||||
|
+ p->length = 128;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static struct packed_ushort __attribute__((noinline)) next(struct source *p)
|
||||||
|
+{
|
||||||
|
+ struct packed_ushort rv;
|
||||||
|
+
|
||||||
|
+ if (p->pos >= p->length) {
|
||||||
|
+ if (flag) {
|
||||||
|
+ flag = 0;
|
||||||
|
+ fetch(p);
|
||||||
|
+ return next(p);
|
||||||
|
+ }
|
||||||
|
+ flag = 1;
|
||||||
|
+ rv.ucs = 0xffff;
|
||||||
|
+ return rv;
|
||||||
|
+ }
|
||||||
|
+ rv.ucs = 0;
|
||||||
|
+ return rv;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int main(void)
|
||||||
|
+{
|
||||||
|
+ struct source s;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ s.pos = 0;
|
||||||
|
+ s.length = 0;
|
||||||
|
+ flag = 0;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < 16; i++) {
|
||||||
|
+ struct packed_ushort rv = next(&s);
|
||||||
|
+ if ((i == 0 && rv.ucs != 0xffff)
|
||||||
|
+ || (i > 0 && rv.ucs != 0))
|
||||||
|
+ abort();
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/gcc/tree.c b/gcc/tree.c
|
||||||
|
index 3c17694c703..5c1374d6fb1 100644
|
||||||
|
--- a/gcc/tree.c
|
||||||
|
+++ b/gcc/tree.c
|
||||||
|
@@ -5216,6 +5216,12 @@ fld_worklist_push (tree t, class free_lang_data_d *fld)
|
||||||
|
static tree
|
||||||
|
fld_simplified_type_name (tree type)
|
||||||
|
{
|
||||||
|
+ /* Simplify type will cause that struct A and struct A within
|
||||||
|
+ struct B are different type pointers, so skip it in structure
|
||||||
|
+ optimizations. */
|
||||||
|
+ if (flag_ipa_struct_reorg)
|
||||||
|
+ return TYPE_NAME (type);
|
||||||
|
+
|
||||||
|
if (!TYPE_NAME (type) || TREE_CODE (TYPE_NAME (type)) != TYPE_DECL)
|
||||||
|
return TYPE_NAME (type);
|
||||||
|
/* Drop TYPE_DECLs in TYPE_NAME in favor of the identifier in the
|
||||||
|
@@ -5454,6 +5460,11 @@ fld_simplified_type (tree t, class free_lang_data_d *fld)
|
||||||
|
{
|
||||||
|
if (!t)
|
||||||
|
return t;
|
||||||
|
+ /* Simplify type will cause that struct A and struct A within
|
||||||
|
+ struct B are different type pointers, so skip it in structure
|
||||||
|
+ optimizations. */
|
||||||
|
+ if (flag_ipa_struct_reorg)
|
||||||
|
+ return t;
|
||||||
|
if (POINTER_TYPE_P (t))
|
||||||
|
return fld_incomplete_type_of (t, fld);
|
||||||
|
/* FIXME: This triggers verification error, see PR88140. */
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
622
0017-mcmodel-Enable-mcmodel-medium-on-kunpeng.patch
Normal file
622
0017-mcmodel-Enable-mcmodel-medium-on-kunpeng.patch
Normal file
@ -0,0 +1,622 @@
|
|||||||
|
From 4d76b521d9bb539556011304b8a76dea1e2657a1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: bule <bule1@huawei.com>
|
||||||
|
Date: Fri, 6 Aug 2021 10:20:54 +0800
|
||||||
|
Subject: [PATCH 17/22] [mcmodel] Enable mcmodel=medium on kunpeng
|
||||||
|
|
||||||
|
Enable mcmodel=medium on kunpeng
|
||||||
|
|
||||||
|
diff --git a/gcc/combine.c b/gcc/combine.c
|
||||||
|
index 35505cc5311..497e53289ca 100644
|
||||||
|
--- a/gcc/combine.c
|
||||||
|
+++ b/gcc/combine.c
|
||||||
|
@@ -1923,6 +1923,12 @@ can_combine_p (rtx_insn *insn, rtx_insn *i3, rtx_insn *pred ATTRIBUTE_UNUSED,
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SET:
|
||||||
|
+ /* If the set is a symbol loaded by medium code model unspec
|
||||||
|
+ escape this combine. */
|
||||||
|
+ if (GET_CODE (SET_SRC (elt)) == UNSPEC
|
||||||
|
+ && XVECLEN (SET_SRC (elt), 0) != 0
|
||||||
|
+ && targetm.medium_symbol_p (SET_SRC (elt)))
|
||||||
|
+ return 0;
|
||||||
|
/* Ignore SETs whose result isn't used but not those that
|
||||||
|
have side-effects. */
|
||||||
|
if (find_reg_note (insn, REG_UNUSED, SET_DEST (elt))
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
|
||||||
|
index ee7bed34924..21828803480 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64-opts.h
|
||||||
|
+++ b/gcc/config/aarch64/aarch64-opts.h
|
||||||
|
@@ -66,6 +66,10 @@ enum aarch64_code_model {
|
||||||
|
/* -fpic for small memory model.
|
||||||
|
GOT size to 28KiB (4K*8-4K) or 3580 entries. */
|
||||||
|
AARCH64_CMODEL_SMALL_SPIC,
|
||||||
|
+ /* Using movk insn sequence to do 64bit PC relative relocation. */
|
||||||
|
+ AARCH64_CMODEL_MEDIUM,
|
||||||
|
+ /* Using movk insn sequence to do 64bit PC relative got relocation. */
|
||||||
|
+ AARCH64_CMODEL_MEDIUM_PIC,
|
||||||
|
/* No assumptions about addresses of code and data.
|
||||||
|
The PIC variant is not yet implemented. */
|
||||||
|
AARCH64_CMODEL_LARGE
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
|
||||||
|
index bebd1b36228..226f3a8ff01 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64-protos.h
|
||||||
|
+++ b/gcc/config/aarch64/aarch64-protos.h
|
||||||
|
@@ -95,9 +95,11 @@
|
||||||
|
*/
|
||||||
|
enum aarch64_symbol_type
|
||||||
|
{
|
||||||
|
+ SYMBOL_MEDIUM_ABSOLUTE,
|
||||||
|
SYMBOL_SMALL_ABSOLUTE,
|
||||||
|
SYMBOL_SMALL_GOT_28K,
|
||||||
|
SYMBOL_SMALL_GOT_4G,
|
||||||
|
+ SYMBOL_MEDIUM_GOT_4G,
|
||||||
|
SYMBOL_SMALL_TLSGD,
|
||||||
|
SYMBOL_SMALL_TLSDESC,
|
||||||
|
SYMBOL_SMALL_TLSIE,
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
|
||||||
|
index 79dc8f186f4..f78942b04c6 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64.c
|
||||||
|
+++ b/gcc/config/aarch64/aarch64.c
|
||||||
|
@@ -3127,6 +3127,29 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
|
||||||
|
emit_insn (gen_add_losym (dest, tmp_reg, imm));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
+ case SYMBOL_MEDIUM_ABSOLUTE:
|
||||||
|
+ {
|
||||||
|
+ rtx tmp_reg = dest;
|
||||||
|
+ machine_mode mode = GET_MODE (dest);
|
||||||
|
+
|
||||||
|
+ gcc_assert (mode == Pmode || mode == ptr_mode);
|
||||||
|
+ if (can_create_pseudo_p ())
|
||||||
|
+ tmp_reg = gen_reg_rtx (mode);
|
||||||
|
+
|
||||||
|
+ if (mode == DImode)
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_load_symbol_medium_di (dest, tmp_reg, imm));
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_load_symbol_medium_si (dest, tmp_reg, imm));
|
||||||
|
+ }
|
||||||
|
+ if (REG_P (dest))
|
||||||
|
+ {
|
||||||
|
+ set_unique_reg_note (get_last_insn (), REG_EQUAL, copy_rtx (imm));
|
||||||
|
+ }
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
case SYMBOL_TINY_ABSOLUTE:
|
||||||
|
emit_insn (gen_rtx_SET (dest, imm));
|
||||||
|
@@ -3249,6 +3272,60 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm,
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ case SYMBOL_MEDIUM_GOT_4G:
|
||||||
|
+ {
|
||||||
|
+ rtx tmp_reg = dest;
|
||||||
|
+ machine_mode mode = GET_MODE (dest);
|
||||||
|
+ if (can_create_pseudo_p ())
|
||||||
|
+ {
|
||||||
|
+ tmp_reg = gen_reg_rtx (mode);
|
||||||
|
+ }
|
||||||
|
+ rtx insn;
|
||||||
|
+ rtx mem;
|
||||||
|
+ rtx s = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
|
||||||
|
+
|
||||||
|
+ if (mode == DImode)
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_load_symbol_medium_di (tmp_reg, dest, s));
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_load_symbol_medium_si (tmp_reg, dest, s));
|
||||||
|
+ }
|
||||||
|
+ if (REG_P (dest))
|
||||||
|
+ {
|
||||||
|
+ set_unique_reg_note (get_last_insn (), REG_EQUAL, copy_rtx (s));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (mode == ptr_mode)
|
||||||
|
+ {
|
||||||
|
+ if (mode == DImode)
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_get_gotoff_di (dest, imm));
|
||||||
|
+ insn = gen_ldr_got_medium_di (dest, tmp_reg, dest);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ emit_insn (gen_get_gotoff_si (dest, imm));
|
||||||
|
+ insn = gen_ldr_got_medium_si (dest, tmp_reg, dest);
|
||||||
|
+ }
|
||||||
|
+ mem = XVECEXP (SET_SRC (insn), 0, 0);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ gcc_assert (mode == Pmode);
|
||||||
|
+ emit_insn (gen_get_gotoff_di (dest, imm));
|
||||||
|
+ insn = gen_ldr_got_medium_sidi (dest, tmp_reg, dest);
|
||||||
|
+ mem = XVECEXP (XEXP (SET_SRC (insn), 0), 0, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ gcc_assert (GET_CODE (mem) == MEM);
|
||||||
|
+ MEM_READONLY_P (mem) = 1;
|
||||||
|
+ MEM_NOTRAP_P (mem) = 1;
|
||||||
|
+ emit_insn (insn);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
case SYMBOL_SMALL_TLSGD:
|
||||||
|
{
|
||||||
|
rtx_insn *insns;
|
||||||
|
@@ -5256,11 +5333,12 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
- case SYMBOL_SMALL_TLSGD:
|
||||||
|
- case SYMBOL_SMALL_TLSDESC:
|
||||||
|
+ case SYMBOL_SMALL_TLSGD:
|
||||||
|
+ case SYMBOL_SMALL_TLSDESC:
|
||||||
|
case SYMBOL_SMALL_TLSIE:
|
||||||
|
case SYMBOL_SMALL_GOT_28K:
|
||||||
|
case SYMBOL_SMALL_GOT_4G:
|
||||||
|
+ case SYMBOL_MEDIUM_GOT_4G:
|
||||||
|
case SYMBOL_TINY_GOT:
|
||||||
|
case SYMBOL_TINY_TLSIE:
|
||||||
|
if (const_offset != 0)
|
||||||
|
@@ -5279,6 +5357,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
|
||||||
|
case SYMBOL_TLSLE24:
|
||||||
|
case SYMBOL_TLSLE32:
|
||||||
|
case SYMBOL_TLSLE48:
|
||||||
|
+ case SYMBOL_MEDIUM_ABSOLUTE:
|
||||||
|
aarch64_load_symref_appropriately (dest, imm, sty);
|
||||||
|
return;
|
||||||
|
|
||||||
|
@@ -9389,7 +9468,14 @@ aarch64_classify_address (struct aarch64_address_info *info,
|
||||||
|
if (GET_CODE (sym) == SYMBOL_REF
|
||||||
|
&& offset.is_constant (&const_offset)
|
||||||
|
&& (aarch64_classify_symbol (sym, const_offset)
|
||||||
|
- == SYMBOL_SMALL_ABSOLUTE))
|
||||||
|
+ == SYMBOL_SMALL_ABSOLUTE
|
||||||
|
+ /* Fix fail on dbl_mov_immediate_1.c. If end up here with
|
||||||
|
+ MEDIUM_ABSOLUTE, the symbol is a constant number that is
|
||||||
|
+ forced to memory in reload pass, which is ok to go on with
|
||||||
|
+ the original design that subtitude the mov to
|
||||||
|
+ 'adrp and ldr :losum'. */
|
||||||
|
+ || aarch64_classify_symbol (sym, const_offset)
|
||||||
|
+ == SYMBOL_MEDIUM_ABSOLUTE))
|
||||||
|
{
|
||||||
|
/* The symbol and offset must be aligned to the access size. */
|
||||||
|
unsigned int align;
|
||||||
|
@@ -11346,7 +11432,13 @@ static inline bool
|
||||||
|
aarch64_can_use_per_function_literal_pools_p (void)
|
||||||
|
{
|
||||||
|
return (aarch64_pcrelative_literal_loads
|
||||||
|
- || aarch64_cmodel == AARCH64_CMODEL_LARGE);
|
||||||
|
+ || aarch64_cmodel == AARCH64_CMODEL_LARGE
|
||||||
|
+ /* Fix const9.C so that constants goes to function_literal_pools.
|
||||||
|
+ According to the orignal design of aarch64 mcmodel=medium, we
|
||||||
|
+ don't care where this symbol is put. For the benefit of code size
|
||||||
|
+ and behaviour consistent with other mcmodel, put it into
|
||||||
|
+ function_literal_pools. */
|
||||||
|
+ || aarch64_cmodel == AARCH64_CMODEL_MEDIUM);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
@@ -13003,6 +13095,13 @@ cost_plus:
|
||||||
|
if (speed)
|
||||||
|
*cost += extra_cost->alu.arith;
|
||||||
|
}
|
||||||
|
+ else if (aarch64_cmodel == AARCH64_CMODEL_MEDIUM
|
||||||
|
+ || aarch64_cmodel == AARCH64_CMODEL_MEDIUM_PIC)
|
||||||
|
+ {
|
||||||
|
+ /* 4 movs adr sub add 2movs ldr. */
|
||||||
|
+ if (speed)
|
||||||
|
+ *cost += 7*extra_cost->alu.arith;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (flag_pic)
|
||||||
|
{
|
||||||
|
@@ -13010,6 +13109,8 @@ cost_plus:
|
||||||
|
*cost += COSTS_N_INSNS (1);
|
||||||
|
if (speed)
|
||||||
|
*cost += extra_cost->ldst.load;
|
||||||
|
+ if (aarch64_cmodel == AARCH64_CMODEL_MEDIUM_PIC)
|
||||||
|
+ *cost += 2*extra_cost->alu.arith;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
@@ -14373,6 +14474,7 @@ initialize_aarch64_tls_size (struct gcc_options *opts)
|
||||||
|
if (aarch64_tls_size > 32)
|
||||||
|
aarch64_tls_size = 32;
|
||||||
|
break;
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM:
|
||||||
|
case AARCH64_CMODEL_LARGE:
|
||||||
|
/* The maximum TLS size allowed under large is 16E.
|
||||||
|
FIXME: 16E should be 64bit, we only support 48bit offset now. */
|
||||||
|
@@ -15266,6 +15368,12 @@ initialize_aarch64_code_model (struct gcc_options *opts)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM:
|
||||||
|
+ if (opts->x_flag_pic)
|
||||||
|
+ {
|
||||||
|
+ aarch64_cmodel = AARCH64_CMODEL_MEDIUM_PIC;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
case AARCH64_CMODEL_LARGE:
|
||||||
|
if (opts->x_flag_pic)
|
||||||
|
sorry ("code model %qs with %<-f%s%>", "large",
|
||||||
|
@@ -15276,6 +15384,7 @@ initialize_aarch64_code_model (struct gcc_options *opts)
|
||||||
|
case AARCH64_CMODEL_TINY_PIC:
|
||||||
|
case AARCH64_CMODEL_SMALL_PIC:
|
||||||
|
case AARCH64_CMODEL_SMALL_SPIC:
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM_PIC:
|
||||||
|
gcc_unreachable ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -15286,6 +15395,7 @@ static void
|
||||||
|
aarch64_option_save (struct cl_target_option *ptr, struct gcc_options *opts)
|
||||||
|
{
|
||||||
|
ptr->x_aarch64_override_tune_string = opts->x_aarch64_override_tune_string;
|
||||||
|
+ ptr->x_aarch64_data_threshold = opts->x_aarch64_data_threshold;
|
||||||
|
ptr->x_aarch64_branch_protection_string
|
||||||
|
= opts->x_aarch64_branch_protection_string;
|
||||||
|
}
|
||||||
|
@@ -15301,6 +15411,7 @@ aarch64_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)
|
||||||
|
opts->x_explicit_arch = ptr->x_explicit_arch;
|
||||||
|
selected_arch = aarch64_get_arch (ptr->x_explicit_arch);
|
||||||
|
opts->x_aarch64_override_tune_string = ptr->x_aarch64_override_tune_string;
|
||||||
|
+ opts->x_aarch64_data_threshold = ptr->x_aarch64_data_threshold;
|
||||||
|
opts->x_aarch64_branch_protection_string
|
||||||
|
= ptr->x_aarch64_branch_protection_string;
|
||||||
|
if (opts->x_aarch64_branch_protection_string)
|
||||||
|
@@ -16169,6 +16280,8 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
|
||||||
|
|
||||||
|
case AARCH64_CMODEL_SMALL_SPIC:
|
||||||
|
case AARCH64_CMODEL_SMALL_PIC:
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM_PIC:
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM:
|
||||||
|
case AARCH64_CMODEL_SMALL:
|
||||||
|
return SYMBOL_SMALL_ABSOLUTE;
|
||||||
|
|
||||||
|
@@ -16205,6 +16318,7 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
|
||||||
|
return SYMBOL_TINY_ABSOLUTE;
|
||||||
|
|
||||||
|
case AARCH64_CMODEL_SMALL:
|
||||||
|
+ AARCH64_SMALL_ROUTINE:
|
||||||
|
/* Same reasoning as the tiny code model, but the offset cap here is
|
||||||
|
1MB, allowing +/-3.9GB for the offset to the symbol. */
|
||||||
|
|
||||||
|
@@ -16228,7 +16342,50 @@ aarch64_classify_symbol (rtx x, HOST_WIDE_INT offset)
|
||||||
|
? SYMBOL_SMALL_GOT_28K : SYMBOL_SMALL_GOT_4G);
|
||||||
|
return SYMBOL_SMALL_ABSOLUTE;
|
||||||
|
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM:
|
||||||
|
+ {
|
||||||
|
+ tree decl_local = SYMBOL_REF_DECL (x);
|
||||||
|
+ if (decl_local != NULL
|
||||||
|
+ && tree_fits_uhwi_p (DECL_SIZE_UNIT (decl_local)))
|
||||||
|
+ {
|
||||||
|
+ HOST_WIDE_INT size = tree_to_uhwi (DECL_SIZE_UNIT (decl_local));
|
||||||
|
+ /* If the data is smaller than the threshold, goto
|
||||||
|
+ the small code model. Else goto the large code
|
||||||
|
+ model. */
|
||||||
|
+ if (size >= HOST_WIDE_INT (aarch64_data_threshold))
|
||||||
|
+ goto AARCH64_LARGE_ROUTINE;
|
||||||
|
+ }
|
||||||
|
+ goto AARCH64_SMALL_ROUTINE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM_PIC:
|
||||||
|
+ {
|
||||||
|
+ tree decl_local = SYMBOL_REF_DECL (x);
|
||||||
|
+ if (decl_local != NULL
|
||||||
|
+ && tree_fits_uhwi_p (DECL_SIZE_UNIT (decl_local)))
|
||||||
|
+ {
|
||||||
|
+ HOST_WIDE_INT size = tree_to_uhwi (DECL_SIZE_UNIT (decl_local));
|
||||||
|
+ if (size < HOST_WIDE_INT (aarch64_data_threshold))
|
||||||
|
+ {
|
||||||
|
+ if (!aarch64_symbol_binds_local_p (x))
|
||||||
|
+ {
|
||||||
|
+ /* flag_pic is 2 only when -fPIC is on, when we should
|
||||||
|
+ use 4G GOT. */
|
||||||
|
+ return flag_pic == 2 ? SYMBOL_SMALL_GOT_4G
|
||||||
|
+ : SYMBOL_SMALL_GOT_28K ;
|
||||||
|
+ }
|
||||||
|
+ return SYMBOL_SMALL_ABSOLUTE;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (!aarch64_symbol_binds_local_p (x))
|
||||||
|
+ {
|
||||||
|
+ return SYMBOL_MEDIUM_GOT_4G;
|
||||||
|
+ }
|
||||||
|
+ return SYMBOL_MEDIUM_ABSOLUTE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
case AARCH64_CMODEL_LARGE:
|
||||||
|
+ AARCH64_LARGE_ROUTINE:
|
||||||
|
/* This is alright even in PIC code as the constant
|
||||||
|
pool reference is always PC relative and within
|
||||||
|
the same translation unit. */
|
||||||
|
@@ -19352,6 +19509,8 @@ aarch64_asm_preferred_eh_data_format (int code ATTRIBUTE_UNUSED, int global)
|
||||||
|
case AARCH64_CMODEL_SMALL:
|
||||||
|
case AARCH64_CMODEL_SMALL_PIC:
|
||||||
|
case AARCH64_CMODEL_SMALL_SPIC:
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM:
|
||||||
|
+ case AARCH64_CMODEL_MEDIUM_PIC:
|
||||||
|
/* text+got+data < 4Gb. 4-byte signed relocs are sufficient
|
||||||
|
for everything. */
|
||||||
|
type = DW_EH_PE_sdata4;
|
||||||
|
@@ -22605,7 +22764,14 @@ aarch64_empty_mask_is_expensive (unsigned)
|
||||||
|
bool
|
||||||
|
aarch64_use_pseudo_pic_reg (void)
|
||||||
|
{
|
||||||
|
- return aarch64_cmodel == AARCH64_CMODEL_SMALL_SPIC;
|
||||||
|
+ /* flag_pic is 2 when -fPIC is on, where we do not need the pseudo
|
||||||
|
+ pic reg. In medium code mode, when combine with -fpie/-fpic, there are
|
||||||
|
+ possibility that some symbol size smaller than the -mlarge-data-threshold
|
||||||
|
+ will still use SMALL_SPIC relocation, which need the pseudo pic reg.
|
||||||
|
+ Fix spill_1.c fail. */
|
||||||
|
+ return aarch64_cmodel == AARCH64_CMODEL_SMALL_SPIC
|
||||||
|
+ || (aarch64_cmodel == AARCH64_CMODEL_MEDIUM_PIC
|
||||||
|
+ && flag_pic != 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Implement TARGET_UNSPEC_MAY_TRAP_P. */
|
||||||
|
@@ -22615,6 +22781,7 @@ aarch64_unspec_may_trap_p (const_rtx x, unsigned flags)
|
||||||
|
{
|
||||||
|
switch (XINT (x, 1))
|
||||||
|
{
|
||||||
|
+ case UNSPEC_GOTMEDIUMPIC4G:
|
||||||
|
case UNSPEC_GOTSMALLPIC:
|
||||||
|
case UNSPEC_GOTSMALLPIC28K:
|
||||||
|
case UNSPEC_GOTTINYPIC:
|
||||||
|
@@ -22976,6 +23143,18 @@ aarch64_estimated_poly_value (poly_int64 val)
|
||||||
|
return val.coeffs[0] + val.coeffs[1] * over_128 / 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Implement TARGET_MEDIUM_SYMBOL_P.
|
||||||
|
+ Return true if x is a symbol loaded by UNSPEC_LOAD_SYMBOL_MEDIUM. */
|
||||||
|
+bool
|
||||||
|
+aarch64_medium_symbol_p (rtx x)
|
||||||
|
+{
|
||||||
|
+ if (GET_CODE (x) != UNSPEC)
|
||||||
|
+ {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ return XINT (x, 1) == UNSPEC_LOAD_SYMBOL_MEDIUM;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
|
||||||
|
/* Return true for types that could be supported as SIMD return or
|
||||||
|
argument types. */
|
||||||
|
@@ -24015,6 +24194,9 @@ aarch64_libgcc_floating_mode_supported_p
|
||||||
|
#undef TARGET_ESTIMATED_POLY_VALUE
|
||||||
|
#define TARGET_ESTIMATED_POLY_VALUE aarch64_estimated_poly_value
|
||||||
|
|
||||||
|
+#undef TARGET_MEDIUM_SYMBOL_P
|
||||||
|
+#define TARGET_MEDIUM_SYMBOL_P aarch64_medium_symbol_p
|
||||||
|
+
|
||||||
|
#undef TARGET_ATTRIBUTE_TABLE
|
||||||
|
#define TARGET_ATTRIBUTE_TABLE aarch64_attribute_table
|
||||||
|
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
|
||||||
|
index 51148846345..8fc92d13dcb 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64.h
|
||||||
|
+++ b/gcc/config/aarch64/aarch64.h
|
||||||
|
@@ -33,6 +33,10 @@
|
||||||
|
|
||||||
|
#define REGISTER_TARGET_PRAGMAS() aarch64_register_pragmas ()
|
||||||
|
|
||||||
|
+/* Default threshold 64-bit relocation data
|
||||||
|
+ with aarch64 medium memory model. */
|
||||||
|
+#define AARCH64_DEFAULT_LARGE_DATA_THRESHOLD 65536
|
||||||
|
+
|
||||||
|
/* Target machine storage layout. */
|
||||||
|
|
||||||
|
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
|
||||||
|
index 58445dea941..ee80261f1ac 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64.md
|
||||||
|
+++ b/gcc/config/aarch64/aarch64.md
|
||||||
|
@@ -224,6 +224,9 @@
|
||||||
|
UNSPEC_RSQRTS
|
||||||
|
UNSPEC_NZCV
|
||||||
|
UNSPEC_XPACLRI
|
||||||
|
+ UNSPEC_GOTMEDIUMPIC4G
|
||||||
|
+ UNSPEC_GET_GOTOFF
|
||||||
|
+ UNSPEC_LOAD_SYMBOL_MEDIUM
|
||||||
|
UNSPEC_LD1_SVE
|
||||||
|
UNSPEC_ST1_SVE
|
||||||
|
UNSPEC_LDNT1_SVE
|
||||||
|
@@ -6792,6 +6795,39 @@
|
||||||
|
[(set_attr "type" "load_4")]
|
||||||
|
)
|
||||||
|
|
||||||
|
+(define_insn "get_gotoff_<mode>"
|
||||||
|
+ [(set (match_operand:GPI 0 "register_operand" "=r")
|
||||||
|
+ (unspec:GPI [(match_operand 1 "aarch64_valid_symref" "S")]
|
||||||
|
+ UNSPEC_GET_GOTOFF))]
|
||||||
|
+ ""
|
||||||
|
+ "movz\\t%x0, :gotoff_g1:%A1\;movk\\t%x0, :gotoff_g0_nc:%A1"
|
||||||
|
+ [(set_attr "type" "multiple")
|
||||||
|
+ (set_attr "length" "8")]
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+(define_insn "ldr_got_medium_<mode>"
|
||||||
|
+ [(set (match_operand:PTR 0 "register_operand" "=r")
|
||||||
|
+ (unspec:PTR [(mem:PTR (lo_sum:PTR
|
||||||
|
+ (match_operand:PTR 1 "register_operand" "r")
|
||||||
|
+ (match_operand:PTR 2 "register_operand" "r")))]
|
||||||
|
+ UNSPEC_GOTMEDIUMPIC4G))]
|
||||||
|
+ ""
|
||||||
|
+ "ldr\\t%0, [%1, %2]"
|
||||||
|
+ [(set_attr "type" "load_4")]
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+(define_insn "ldr_got_medium_sidi"
|
||||||
|
+ [(set (match_operand:DI 0 "register_operand" "=r")
|
||||||
|
+ (zero_extend:DI
|
||||||
|
+ (unspec:SI [(mem:SI (lo_sum:DI
|
||||||
|
+ (match_operand:DI 1 "register_operand" "r")
|
||||||
|
+ (match_operand:DI 2 "register_operand" "r")))]
|
||||||
|
+ UNSPEC_GOTMEDIUMPIC4G)))]
|
||||||
|
+ "TARGET_ILP32"
|
||||||
|
+ "ldr\\t%0, [%1, %2]"
|
||||||
|
+ [(set_attr "type" "load_4")]
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
(define_insn "ldr_got_small_28k_<mode>"
|
||||||
|
[(set (match_operand:PTR 0 "register_operand" "=r")
|
||||||
|
(unspec:PTR [(mem:PTR (lo_sum:PTR
|
||||||
|
@@ -6955,6 +6991,23 @@
|
||||||
|
(set_attr "length" "12")]
|
||||||
|
)
|
||||||
|
|
||||||
|
+(define_insn "load_symbol_medium_<mode>"
|
||||||
|
+ [(set (match_operand:GPI 0 "register_operand" "=r")
|
||||||
|
+ (unspec:GPI [(match_operand 2 "aarch64_valid_symref" "S")]
|
||||||
|
+ UNSPEC_LOAD_SYMBOL_MEDIUM))
|
||||||
|
+ (clobber (match_operand:GPI 1 "register_operand" "=r"))]
|
||||||
|
+ ""
|
||||||
|
+ "movz\\t%x0, :prel_g3:%A2\;\\
|
||||||
|
+movk\\t%x0, :prel_g2_nc:%A2\;\\
|
||||||
|
+movk\\t%x0, :prel_g1_nc:%A2\;\\
|
||||||
|
+movk\\t%x0, :prel_g0_nc:%A2\;\\
|
||||||
|
+adr\\t%x1, .\;\\
|
||||||
|
+sub\\t%x1, %x1, 0x4\;\\
|
||||||
|
+add\\t%x0, %x0, %x1"
|
||||||
|
+ [(set_attr "type" "multiple")
|
||||||
|
+ (set_attr "length" "28")]
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
(define_expand "tlsdesc_small_<mode>"
|
||||||
|
[(unspec:PTR [(match_operand 0 "aarch64_valid_symref")] UNSPEC_TLSDESC)]
|
||||||
|
"TARGET_TLS_DESC"
|
||||||
|
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
|
||||||
|
index 4539156d6f4..bb888461ab0 100644
|
||||||
|
--- a/gcc/config/aarch64/aarch64.opt
|
||||||
|
+++ b/gcc/config/aarch64/aarch64.opt
|
||||||
|
@@ -27,6 +27,10 @@ enum aarch64_processor explicit_tune_core = aarch64_none
|
||||||
|
TargetVariable
|
||||||
|
enum aarch64_arch explicit_arch = aarch64_no_arch
|
||||||
|
|
||||||
|
+;; -mlarge-data-threshold=
|
||||||
|
+TargetSave
|
||||||
|
+int x_aarch64_data_threshold
|
||||||
|
+
|
||||||
|
TargetSave
|
||||||
|
const char *x_aarch64_override_tune_string
|
||||||
|
|
||||||
|
@@ -60,9 +64,16 @@ Enum(cmodel) String(tiny) Value(AARCH64_CMODEL_TINY)
|
||||||
|
EnumValue
|
||||||
|
Enum(cmodel) String(small) Value(AARCH64_CMODEL_SMALL)
|
||||||
|
|
||||||
|
+EnumValue
|
||||||
|
+Enum(cmodel) String(medium) Value(AARCH64_CMODEL_MEDIUM)
|
||||||
|
+
|
||||||
|
EnumValue
|
||||||
|
Enum(cmodel) String(large) Value(AARCH64_CMODEL_LARGE)
|
||||||
|
|
||||||
|
+mlarge-data-threshold=
|
||||||
|
+Target RejectNegative Joined UInteger Var(aarch64_data_threshold) Init(AARCH64_DEFAULT_LARGE_DATA_THRESHOLD)
|
||||||
|
+-mlarge-data-threshold=<number> Data greater than given threshold will be assume that it should be relocated using 64-bit relocation.
|
||||||
|
+
|
||||||
|
mbig-endian
|
||||||
|
Target Report RejectNegative Mask(BIG_END)
|
||||||
|
Assume target CPU is configured as big endian.
|
||||||
|
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
|
||||||
|
index fcb7245e95c..0508fce57a7 100644
|
||||||
|
--- a/gcc/doc/tm.texi
|
||||||
|
+++ b/gcc/doc/tm.texi
|
||||||
|
@@ -6983,6 +6983,11 @@ things like cost calculations or profiling frequencies. The default
|
||||||
|
implementation returns the lowest possible value of @var{val}.
|
||||||
|
@end deftypefn
|
||||||
|
|
||||||
|
+@deftypefn {Target Hook} bool TARGET_MEDIUM_SYMBOL_P (rtx @var{x})
|
||||||
|
+Return true if the input rtx is a symbol loaded by kunpeng medium code
|
||||||
|
+model.
|
||||||
|
+@end deftypefn
|
||||||
|
+
|
||||||
|
@node Scheduling
|
||||||
|
@section Adjusting the Instruction Scheduler
|
||||||
|
|
||||||
|
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
|
||||||
|
index c17209daa51..3b70ea4841a 100644
|
||||||
|
--- a/gcc/doc/tm.texi.in
|
||||||
|
+++ b/gcc/doc/tm.texi.in
|
||||||
|
@@ -4701,6 +4701,8 @@ Define this macro if a non-short-circuit operation produced by
|
||||||
|
|
||||||
|
@hook TARGET_ESTIMATED_POLY_VALUE
|
||||||
|
|
||||||
|
+@hook TARGET_MEDIUM_SYMBOL_P
|
||||||
|
+
|
||||||
|
@node Scheduling
|
||||||
|
@section Adjusting the Instruction Scheduler
|
||||||
|
|
||||||
|
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
|
||||||
|
index d61cadb5208..bad8208cd22 100644
|
||||||
|
--- a/gcc/dwarf2out.c
|
||||||
|
+++ b/gcc/dwarf2out.c
|
||||||
|
@@ -14501,14 +14501,17 @@ const_ok_for_output_1 (rtx rtl)
|
||||||
|
/* If delegitimize_address couldn't do anything with the UNSPEC, and
|
||||||
|
the target hook doesn't explicitly allow it in debug info, assume
|
||||||
|
we can't express it in the debug info. */
|
||||||
|
- /* Don't complain about TLS UNSPECs, those are just too hard to
|
||||||
|
- delegitimize. Note this could be a non-decl SYMBOL_REF such as
|
||||||
|
- one in a constant pool entry, so testing SYMBOL_REF_TLS_MODEL
|
||||||
|
- rather than DECL_THREAD_LOCAL_P is not just an optimization. */
|
||||||
|
+ /* Don't complain about TLS UNSPECs and aarch64 medium code model
|
||||||
|
+ related UNSPECs, those are just too hard to delegitimize. Note
|
||||||
|
+ this could be a non-decl SYMBOL_REF such as one in a constant
|
||||||
|
+ pool entry, so testing SYMBOL_REF_TLS_MODEL rather than
|
||||||
|
+ DECL_THREAD_LOCAL_P is not just an optimization. */
|
||||||
|
if (flag_checking
|
||||||
|
&& (XVECLEN (rtl, 0) == 0
|
||||||
|
|| GET_CODE (XVECEXP (rtl, 0, 0)) != SYMBOL_REF
|
||||||
|
- || SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0)) == TLS_MODEL_NONE))
|
||||||
|
+ || (!targetm.medium_symbol_p (rtl)
|
||||||
|
+ && SYMBOL_REF_TLS_MODEL (XVECEXP (rtl, 0, 0))
|
||||||
|
+ == TLS_MODEL_NONE)))
|
||||||
|
inform (current_function_decl
|
||||||
|
? DECL_SOURCE_LOCATION (current_function_decl)
|
||||||
|
: UNKNOWN_LOCATION,
|
||||||
|
diff --git a/gcc/target.def b/gcc/target.def
|
||||||
|
index f5a6d507e91..2020564118b 100644
|
||||||
|
--- a/gcc/target.def
|
||||||
|
+++ b/gcc/target.def
|
||||||
|
@@ -3869,6 +3869,13 @@ implementation returns the lowest possible value of @var{val}.",
|
||||||
|
HOST_WIDE_INT, (poly_int64 val),
|
||||||
|
default_estimated_poly_value)
|
||||||
|
|
||||||
|
+DEFHOOK
|
||||||
|
+(medium_symbol_p,
|
||||||
|
+ "Return true if the input rtx is a symbol loaded by kunpeng medium code\n\
|
||||||
|
+model.",
|
||||||
|
+ bool, (rtx x),
|
||||||
|
+ default_medium_symbol_p)
|
||||||
|
+
|
||||||
|
/* Permit speculative instructions in delay slots during delayed-branch
|
||||||
|
scheduling. */
|
||||||
|
DEFHOOK
|
||||||
|
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
|
||||||
|
index 7cb04f30bdb..43a9f0cdf5b 100644
|
||||||
|
--- a/gcc/targhooks.c
|
||||||
|
+++ b/gcc/targhooks.c
|
||||||
|
@@ -1708,6 +1708,13 @@ default_estimated_poly_value (poly_int64 x)
|
||||||
|
return x.coeffs[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* The default implementation of TARGET_MEDIUM_SYMBOL_P. */
|
||||||
|
+bool
|
||||||
|
+default_medium_symbol_p (rtx x ATTRIBUTE_UNUSED)
|
||||||
|
+{
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* For hooks which use the MOVE_RATIO macro, this gives the legacy default
|
||||||
|
behavior. SPEED_P is true if we are compiling for speed. */
|
||||||
|
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
5370
0018-StructReorderFields-Structure-reorder-fields.patch
Normal file
5370
0018-StructReorderFields-Structure-reorder-fields.patch
Normal file
File diff suppressed because it is too large
Load Diff
296
0019-StructReorderFields-Fix-bugs-and-improve-mechanism.patch
Normal file
296
0019-StructReorderFields-Fix-bugs-and-improve-mechanism.patch
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
From 5392e41dcb7d58a80f2864b3c3f600c538fba799 Mon Sep 17 00:00:00 2001
|
||||||
|
From: huangxiaoquan <huangxiaoquan1@huawei.com>
|
||||||
|
Date: Wed, 4 Aug 2021 14:21:08 +0800
|
||||||
|
Subject: [PATCH 19/22] [StructReorderFields] Fix bugs and improve mechanism
|
||||||
|
|
||||||
|
Fix bugs and improve mechanism:
|
||||||
|
|
||||||
|
1. Fixed a bug in multi-layer pointer recording.
|
||||||
|
2. Use new to initialize allocated memory in symbol-summary.h.
|
||||||
|
3. Only enable optimizations in C language.
|
||||||
|
|
||||||
|
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
index 384aa81583c..fe364f742d8 100644
|
||||||
|
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
@@ -173,31 +173,30 @@ lang_c_p (void)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (strcmp (language_string, "GNU GIMPLE") == 0)
|
||||||
|
+ if (lang_GNU_C ())
|
||||||
|
+ {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ else if (strcmp (language_string, "GNU GIMPLE") == 0) // for LTO check
|
||||||
|
{
|
||||||
|
unsigned i = 0;
|
||||||
|
- tree t = NULL;
|
||||||
|
- const char *unit_string = NULL;
|
||||||
|
+ tree t = NULL_TREE;
|
||||||
|
|
||||||
|
FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, t)
|
||||||
|
{
|
||||||
|
- unit_string = TRANSLATION_UNIT_LANGUAGE (t);
|
||||||
|
- if (!unit_string
|
||||||
|
- || (strncmp (unit_string, "GNU C", 5) != 0)
|
||||||
|
- || (!ISDIGIT (unit_string[5])))
|
||||||
|
+ language_string = TRANSLATION_UNIT_LANGUAGE (t);
|
||||||
|
+ if (language_string == NULL
|
||||||
|
+ || strncmp (language_string, "GNU C", 5)
|
||||||
|
+ || (language_string[5] != '\0'
|
||||||
|
+ && !(ISDIGIT (language_string[5]))))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
- else if (strncmp (language_string, "GNU C", 5) == 0
|
||||||
|
- && ISDIGIT (language_string[5]))
|
||||||
|
- {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
return false;
|
||||||
|
+}
|
||||||
|
|
||||||
|
/* Get the number of pointer layers. */
|
||||||
|
|
||||||
|
@@ -1262,7 +1261,7 @@ public:
|
||||||
|
void check_uses (srdecl *decl, vec<srdecl*>&);
|
||||||
|
void check_use (srdecl *decl, gimple *stmt, vec<srdecl*>&);
|
||||||
|
void check_type_and_push (tree newdecl, srdecl *decl,
|
||||||
|
- vec<srdecl*> &worklist, gimple *stmt);
|
||||||
|
+ vec<srdecl*> &worklist, gimple *stmt);
|
||||||
|
void check_other_side (srdecl *decl, tree other, gimple *stmt, vec<srdecl*> &worklist);
|
||||||
|
void check_ptr_layers (tree a_expr, tree b_expr, gimple* stmt);
|
||||||
|
|
||||||
|
@@ -3010,11 +3009,9 @@ ipa_struct_reorg::find_var (tree expr, gimple *stmt)
|
||||||
|
{
|
||||||
|
tree r = TREE_OPERAND (expr, 0);
|
||||||
|
tree orig_type = TREE_TYPE (expr);
|
||||||
|
- if (handled_component_p (r)
|
||||||
|
- || TREE_CODE (r) == MEM_REF)
|
||||||
|
+ if (handled_component_p (r) || TREE_CODE (r) == MEM_REF)
|
||||||
|
{
|
||||||
|
- while (handled_component_p (r)
|
||||||
|
- || TREE_CODE (r) == MEM_REF)
|
||||||
|
+ while (handled_component_p (r) || TREE_CODE (r) == MEM_REF)
|
||||||
|
{
|
||||||
|
if (TREE_CODE (r) == VIEW_CONVERT_EXPR)
|
||||||
|
{
|
||||||
|
@@ -3092,10 +3089,12 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
srdecl *d = find_decl (lhs);
|
||||||
|
if (!d && t)
|
||||||
|
{
|
||||||
|
- current_function->record_decl (t, lhs, -1);
|
||||||
|
+ current_function->record_decl (t, lhs, -1,
|
||||||
|
+ isptrptr (TREE_TYPE (rhs)) ? TREE_TYPE (rhs) : NULL);
|
||||||
|
tree var = SSA_NAME_VAR (lhs);
|
||||||
|
if (var && VOID_POINTER_P (TREE_TYPE (var)))
|
||||||
|
- current_function->record_decl (t, var, -1);
|
||||||
|
+ current_function->record_decl (t, var, -1,
|
||||||
|
+ isptrptr (TREE_TYPE (rhs)) ? TREE_TYPE (rhs) : NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* void * _1; struct arc * _2;
|
||||||
|
@@ -3108,10 +3107,12 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
srdecl *d = find_decl (rhs);
|
||||||
|
if (!d && t)
|
||||||
|
{
|
||||||
|
- current_function->record_decl (t, rhs, -1);
|
||||||
|
+ current_function->record_decl (t, rhs, -1,
|
||||||
|
+ isptrptr (TREE_TYPE (lhs)) ? TREE_TYPE (lhs) : NULL);
|
||||||
|
tree var = SSA_NAME_VAR (rhs);
|
||||||
|
if (var && VOID_POINTER_P (TREE_TYPE (var)))
|
||||||
|
- current_function->record_decl (t, var, -1);
|
||||||
|
+ current_function->record_decl (t, var, -1,
|
||||||
|
+ isptrptr (TREE_TYPE (lhs)) ? TREE_TYPE (lhs) : NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -3529,7 +3530,7 @@ ipa_struct_reorg::maybe_mark_or_record_other_side (tree side, tree other, gimple
|
||||||
|
{
|
||||||
|
/* The type is other, the declaration is side. */
|
||||||
|
current_function->record_decl (type, side, -1,
|
||||||
|
- find_decl (other) ? find_decl (other)->orig_type : NULL);
|
||||||
|
+ isptrptr (TREE_TYPE (other)) ? TREE_TYPE (other) : NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@@ -5111,31 +5112,23 @@ ipa_struct_reorg::propagate_escape_via_original (void)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < types.length (); i++)
|
||||||
|
{
|
||||||
|
- for (unsigned j = 0; j < types[i]->fields.length (); j++)
|
||||||
|
- {
|
||||||
|
- srfield *field = types[i]->fields[j];
|
||||||
|
- if (handled_type (field->fieldtype) && field->type)
|
||||||
|
- {
|
||||||
|
- for (unsigned k = 0; k < types.length (); k++)
|
||||||
|
- {
|
||||||
|
- const char *type1 = get_type_name (field->type->type);
|
||||||
|
- const char *type2 = get_type_name (types[k]->type);
|
||||||
|
- if (type1 == NULL || type2 == NULL)
|
||||||
|
- {
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
- if (type1 == type2 && types[k]->has_escaped ())
|
||||||
|
- {
|
||||||
|
- if (!field->type->has_escaped ())
|
||||||
|
- {
|
||||||
|
- field->type->mark_escape (
|
||||||
|
- escape_via_orig_escape, NULL);
|
||||||
|
- }
|
||||||
|
- break;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
+ for (unsigned j = 0; j < types.length (); j++)
|
||||||
|
+ {
|
||||||
|
+ const char *type1 = get_type_name (types[i]->type);
|
||||||
|
+ const char *type2 = get_type_name (types[j]->type);
|
||||||
|
+ if (type1 == NULL || type2 == NULL)
|
||||||
|
+ {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (type1 == type2 && types[j]->has_escaped ())
|
||||||
|
+ {
|
||||||
|
+ if (!types[i]->has_escaped ())
|
||||||
|
+ {
|
||||||
|
+ types[i]->mark_escape (escape_via_orig_escape, NULL);
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -6683,7 +6676,10 @@ pass_ipa_reorder_fields::gate (function *)
|
||||||
|
&& flag_ipa_reorder_fields
|
||||||
|
/* Don't bother doing anything if the program has errors. */
|
||||||
|
&& !seen_error ()
|
||||||
|
- && flag_lto_partition == LTO_PARTITION_ONE);
|
||||||
|
+ && flag_lto_partition == LTO_PARTITION_ONE
|
||||||
|
+ /* Only enable struct optimizations in C since other
|
||||||
|
+ languages' grammar forbid. */
|
||||||
|
+ && lang_c_p ());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anon namespace
|
||||||
|
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
|
||||||
|
index a223b4dadea..ddf5e35776e 100644
|
||||||
|
--- a/gcc/symbol-summary.h
|
||||||
|
+++ b/gcc/symbol-summary.h
|
||||||
|
@@ -61,10 +61,9 @@ protected:
|
||||||
|
{
|
||||||
|
/* In structure optimizatons, we call new to ensure that
|
||||||
|
the allocated memory is initialized to 0. */
|
||||||
|
- if (flag_ipa_struct_reorg)
|
||||||
|
+ if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
|
||||||
|
return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T ()
|
||||||
|
: new T ();
|
||||||
|
-
|
||||||
|
/* Call gcc_internal_because we do not want to call finalizer for
|
||||||
|
a type T. We call dtor explicitly. */
|
||||||
|
return is_ggc () ? new (ggc_internal_alloc (sizeof (T))) T ()
|
||||||
|
@@ -78,7 +77,7 @@ protected:
|
||||||
|
ggc_delete (item);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
- if (flag_ipa_struct_reorg)
|
||||||
|
+ if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
|
||||||
|
delete item;
|
||||||
|
else
|
||||||
|
m_allocator.remove (item);
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c b/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..23765fc5615
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/rf_mul_layer_ptr_record_bug.c
|
||||||
|
@@ -0,0 +1,30 @@
|
||||||
|
+/* { dg-do compile } */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+
|
||||||
|
+typedef struct T_HASH_ENTRY
|
||||||
|
+{
|
||||||
|
+ unsigned int hash;
|
||||||
|
+ unsigned int klen;
|
||||||
|
+ char *key;
|
||||||
|
+} iHashEntry;
|
||||||
|
+
|
||||||
|
+typedef struct T_HASH
|
||||||
|
+{
|
||||||
|
+ unsigned int size;
|
||||||
|
+ unsigned int fill;
|
||||||
|
+ unsigned int keys;
|
||||||
|
+
|
||||||
|
+ iHashEntry **array;
|
||||||
|
+} uHash;
|
||||||
|
+
|
||||||
|
+uHash *retval;
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+main() {
|
||||||
|
+ retval->array = (iHashEntry **)calloc(sizeof(iHashEntry *), retval->size);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* { dg-final { scan-ipa-dump "Number of structures to transform is 2" "reorder_fields" } } */
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c b/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
|
||||||
|
index 8d687c58b30..54e737ee856 100644
|
||||||
|
--- a/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/rf_pass_conflict.c
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
-// 针对
|
||||||
|
+// For testing:
|
||||||
|
/*
|
||||||
|
-Compile options: /home/hxq/hcc_gcc9.3.0_org_debug/bin/gcc -O3 -g
|
||||||
|
+Compile options: gcc -O3 -g
|
||||||
|
-flto -flto-partition=one -fipa-reorder-fields -fipa-struct-reorg
|
||||||
|
-v -save-temps -fdump-ipa-all-details test.c -o test
|
||||||
|
|
||||||
|
@@ -94,12 +94,11 @@ switch_arcs(arc_t** deleted_arcs, arc_t* arcnew)
|
||||||
|
copy = *test_arc;
|
||||||
|
count++;
|
||||||
|
*test_arc = arcnew[0];
|
||||||
|
- replace_weaker_arc(arcnew, copy.tail, copy.head);
|
||||||
|
+ replace_weaker_arc(arcnew, NULL, NULL);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
diff --git a/gcc/tree.c b/gcc/tree.c
|
||||||
|
index 5c1374d6fb1..89fa469c359 100644
|
||||||
|
--- a/gcc/tree.c
|
||||||
|
+++ b/gcc/tree.c
|
||||||
|
@@ -5219,7 +5219,7 @@ fld_simplified_type_name (tree type)
|
||||||
|
/* Simplify type will cause that struct A and struct A within
|
||||||
|
struct B are different type pointers, so skip it in structure
|
||||||
|
optimizations. */
|
||||||
|
- if (flag_ipa_struct_reorg)
|
||||||
|
+ if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
|
||||||
|
return TYPE_NAME (type);
|
||||||
|
|
||||||
|
if (!TYPE_NAME (type) || TREE_CODE (TYPE_NAME (type)) != TYPE_DECL)
|
||||||
|
@@ -5463,7 +5463,7 @@ fld_simplified_type (tree t, class free_lang_data_d *fld)
|
||||||
|
/* Simplify type will cause that struct A and struct A within
|
||||||
|
struct B are different type pointers, so skip it in structure
|
||||||
|
optimizations. */
|
||||||
|
- if (flag_ipa_struct_reorg)
|
||||||
|
+ if (flag_ipa_reorder_fields || flag_ipa_struct_reorg)
|
||||||
|
return t;
|
||||||
|
if (POINTER_TYPE_P (t))
|
||||||
|
return fld_incomplete_type_of (t, fld);
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
128
0020-Backport-vect-Fix-an-ICE-in-vect_recog_mask_conversi.patch
Normal file
128
0020-Backport-vect-Fix-an-ICE-in-vect_recog_mask_conversi.patch
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
From 633dd654347b6146d6e94d6434e7028617019134 Mon Sep 17 00:00:00 2001
|
||||||
|
From: zhanghaijian <z.zhanghaijian@huawei.com>
|
||||||
|
Date: Mon, 9 Aug 2021 20:18:26 +0800
|
||||||
|
Subject: [PATCH 20/22] [Backport]vect: Fix an ICE in
|
||||||
|
vect_recog_mask_conversion_pattern
|
||||||
|
|
||||||
|
Reference:https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=91d80cf4bd2827dd9c40fe6a7c719c909d79083d
|
||||||
|
|
||||||
|
When processing the cond expression, vect_recog_mask_conversion_pattern
|
||||||
|
doesn't consider the situation that two operands of rhs1 are different
|
||||||
|
vectypes, leading to a vect ICE. This patch adds the identification and
|
||||||
|
handling of the situation to fix the problem.
|
||||||
|
|
||||||
|
diff --git a/gcc/testsuite/gcc.target/aarch64/pr96757.c b/gcc/testsuite/gcc.target/aarch64/pr96757.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..122e39dca0e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.target/aarch64/pr96757.c
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+/* PR target/96757 */
|
||||||
|
+/* { dg-do compile } */
|
||||||
|
+/* { dg-options "-O3" } */
|
||||||
|
+
|
||||||
|
+short
|
||||||
|
+fun1(short i, short j)
|
||||||
|
+{
|
||||||
|
+ return i * j;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int
|
||||||
|
+fun(int a, int b, int c)
|
||||||
|
+{
|
||||||
|
+ int *v, z, k, m;
|
||||||
|
+ short f, d;
|
||||||
|
+ for (int i=0; i<c; i++)
|
||||||
|
+ {
|
||||||
|
+ f= 4 <= d;
|
||||||
|
+ k= a > m;
|
||||||
|
+ z = f > k;
|
||||||
|
+ *v += fun1(z,b);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
|
||||||
|
index 310165084a3..84d7ddb170f 100644
|
||||||
|
--- a/gcc/tree-vect-patterns.c
|
||||||
|
+++ b/gcc/tree-vect-patterns.c
|
||||||
|
@@ -4237,6 +4237,8 @@ vect_recog_mask_conversion_pattern (stmt_vec_info stmt_vinfo, tree *type_out)
|
||||||
|
tree vectype1, vectype2;
|
||||||
|
stmt_vec_info pattern_stmt_info;
|
||||||
|
vec_info *vinfo = stmt_vinfo->vinfo;
|
||||||
|
+ tree rhs1_op0 = NULL_TREE, rhs1_op1 = NULL_TREE;
|
||||||
|
+ tree rhs1_op0_type = NULL_TREE, rhs1_op1_type = NULL_TREE;
|
||||||
|
|
||||||
|
/* Check for MASK_LOAD ans MASK_STORE calls requiring mask conversion. */
|
||||||
|
if (is_gimple_call (last_stmt)
|
||||||
|
@@ -4336,9 +4338,37 @@ vect_recog_mask_conversion_pattern (stmt_vec_info stmt_vinfo, tree *type_out)
|
||||||
|
|
||||||
|
it is better for b1 and b2 to use the mask type associated
|
||||||
|
with int elements rather bool (byte) elements. */
|
||||||
|
- rhs1_type = integer_type_for_mask (TREE_OPERAND (rhs1, 0), vinfo);
|
||||||
|
- if (!rhs1_type)
|
||||||
|
- rhs1_type = TREE_TYPE (TREE_OPERAND (rhs1, 0));
|
||||||
|
+ rhs1_op0 = TREE_OPERAND (rhs1, 0);
|
||||||
|
+ rhs1_op1 = TREE_OPERAND (rhs1, 1);
|
||||||
|
+ if (!rhs1_op0 || !rhs1_op1)
|
||||||
|
+ return NULL;
|
||||||
|
+ rhs1_op0_type = integer_type_for_mask (rhs1_op0, vinfo);
|
||||||
|
+ rhs1_op1_type = integer_type_for_mask (rhs1_op1, vinfo);
|
||||||
|
+
|
||||||
|
+ if (!rhs1_op0_type)
|
||||||
|
+ rhs1_type = TREE_TYPE (rhs1_op0);
|
||||||
|
+ else if (!rhs1_op1_type)
|
||||||
|
+ rhs1_type = TREE_TYPE (rhs1_op1);
|
||||||
|
+ else if (TYPE_PRECISION (rhs1_op0_type)
|
||||||
|
+ != TYPE_PRECISION (rhs1_op1_type))
|
||||||
|
+ {
|
||||||
|
+ int tmp0 = (int) TYPE_PRECISION (rhs1_op0_type)
|
||||||
|
+ - (int) TYPE_PRECISION (TREE_TYPE (lhs));
|
||||||
|
+ int tmp1 = (int) TYPE_PRECISION (rhs1_op1_type)
|
||||||
|
+ - (int) TYPE_PRECISION (TREE_TYPE (lhs));
|
||||||
|
+ if ((tmp0 > 0 && tmp1 > 0) || (tmp0 < 0 && tmp1 < 0))
|
||||||
|
+ {
|
||||||
|
+ if (abs (tmp0) > abs (tmp1))
|
||||||
|
+ rhs1_type = rhs1_op1_type;
|
||||||
|
+ else
|
||||||
|
+ rhs1_type = rhs1_op0_type;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ rhs1_type = build_nonstandard_integer_type
|
||||||
|
+ (TYPE_PRECISION (TREE_TYPE (lhs)), 1);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ rhs1_type = rhs1_op0_type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
@@ -4356,8 +4386,8 @@ vect_recog_mask_conversion_pattern (stmt_vec_info stmt_vinfo, tree *type_out)
|
||||||
|
name from the outset. */
|
||||||
|
if (known_eq (TYPE_VECTOR_SUBPARTS (vectype1),
|
||||||
|
TYPE_VECTOR_SUBPARTS (vectype2))
|
||||||
|
- && (TREE_CODE (rhs1) == SSA_NAME
|
||||||
|
- || rhs1_type == TREE_TYPE (TREE_OPERAND (rhs1, 0))))
|
||||||
|
+ && !rhs1_op0_type
|
||||||
|
+ && !rhs1_op1_type)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* If rhs1 is invariant and we can promote it leave the COND_EXPR
|
||||||
|
@@ -4390,7 +4420,16 @@ vect_recog_mask_conversion_pattern (stmt_vec_info stmt_vinfo, tree *type_out)
|
||||||
|
if (TREE_CODE (rhs1) != SSA_NAME)
|
||||||
|
{
|
||||||
|
tmp = vect_recog_temp_ssa_var (TREE_TYPE (rhs1), NULL);
|
||||||
|
- pattern_stmt = gimple_build_assign (tmp, rhs1);
|
||||||
|
+ if (rhs1_op0_type
|
||||||
|
+ && TYPE_PRECISION (rhs1_op0_type) != TYPE_PRECISION (rhs1_type))
|
||||||
|
+ rhs1_op0 = build_mask_conversion (rhs1_op0,
|
||||||
|
+ vectype2, stmt_vinfo);
|
||||||
|
+ if (rhs1_op1_type
|
||||||
|
+ && TYPE_PRECISION (rhs1_op1_type) != TYPE_PRECISION (rhs1_type))
|
||||||
|
+ rhs1_op1 = build_mask_conversion (rhs1_op1,
|
||||||
|
+ vectype2, stmt_vinfo);
|
||||||
|
+ pattern_stmt = gimple_build_assign (tmp, TREE_CODE (rhs1),
|
||||||
|
+ rhs1_op0, rhs1_op1);
|
||||||
|
rhs1 = tmp;
|
||||||
|
append_pattern_def_seq (stmt_vinfo, pattern_stmt, vectype2,
|
||||||
|
rhs1_type);
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
23
0021-mcmodel-Bugfix-for-mcmodel-medium-on-x86.patch
Normal file
23
0021-mcmodel-Bugfix-for-mcmodel-medium-on-x86.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
From 023c92ac45b727768599a95f7da748158a270753 Mon Sep 17 00:00:00 2001
|
||||||
|
From: bule <bule1@huawei.com>
|
||||||
|
Date: Mon, 16 Aug 2021 11:20:35 +0800
|
||||||
|
Subject: [PATCH 21/22] [mcmodel] Bugfix for mcmodel=medium on x86
|
||||||
|
|
||||||
|
Declare default_medium_symbol_p in targhooks.h which otherwise
|
||||||
|
cause the build failure on x86 platform.
|
||||||
|
|
||||||
|
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
|
||||||
|
index 72f3064e8f8..95c136edc79 100644
|
||||||
|
--- a/gcc/targhooks.h
|
||||||
|
+++ b/gcc/targhooks.h
|
||||||
|
@@ -218,6 +218,7 @@ extern int default_register_move_cost (machine_mode, reg_class_t,
|
||||||
|
reg_class_t);
|
||||||
|
extern bool default_slow_unaligned_access (machine_mode, unsigned int);
|
||||||
|
extern HOST_WIDE_INT default_estimated_poly_value (poly_int64);
|
||||||
|
+extern bool default_medium_symbol_p (rtx);
|
||||||
|
|
||||||
|
extern bool default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT,
|
||||||
|
unsigned int,
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
167
0022-StructReorderFields-Fix-pointer-layer-check-bug.patch
Normal file
167
0022-StructReorderFields-Fix-pointer-layer-check-bug.patch
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
From 1c69390a01d3bf7226fce2a670a0f71731744b04 Mon Sep 17 00:00:00 2001
|
||||||
|
From: huangxiaoquan <huangxiaoquan1@huawei.com>
|
||||||
|
Date: Tue, 17 Aug 2021 15:50:31 +0800
|
||||||
|
Subject: [PATCH 22/22] [StructReorderFields] Fix pointer layer check bug
|
||||||
|
|
||||||
|
In the pointer layer check, the NULL pointer check is added
|
||||||
|
for the escape type mark.
|
||||||
|
|
||||||
|
diff --git a/gcc/ipa-struct-reorg/ipa-struct-reorg.c b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
index fe364f742d8..85986ce5803 100644
|
||||||
|
--- a/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
+++ b/gcc/ipa-struct-reorg/ipa-struct-reorg.c
|
||||||
|
@@ -2235,9 +2235,9 @@ check_record_ptr_usage (gimple *use_stmt, tree ¤t_node,
|
||||||
|
}
|
||||||
|
|
||||||
|
bool res = true;
|
||||||
|
- /* MEM[(long int *)a_1] = _57; (record).
|
||||||
|
+ /* MEM[(long int *)a_1] = _1; (record).
|
||||||
|
If lhs is ssa_name, lhs cannot be the current node.
|
||||||
|
- _283 = _282->flow; (No record). */
|
||||||
|
+ _2 = _1->flow; (No record). */
|
||||||
|
if (TREE_CODE (rhs1) == SSA_NAME)
|
||||||
|
{
|
||||||
|
tree tmp = (rhs1 != current_node) ? rhs1 : lhs;
|
||||||
|
@@ -2285,13 +2285,13 @@ check_record_single_node (gimple *use_stmt, tree ¤t_node,
|
||||||
|
bool res = true;
|
||||||
|
if (TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs1) == MEM_REF)
|
||||||
|
{
|
||||||
|
- /* _257 = MEM[(struct arc_t * *)_17]. */
|
||||||
|
+ /* add such as: _2 = MEM[(struct arc_t * *)_1]. */
|
||||||
|
res = add_node (lhs, *ptr_layers.get (current_node) - 1,
|
||||||
|
ptr_layers, ssa_name_stack);
|
||||||
|
}
|
||||||
|
else if (TREE_CODE (lhs) == MEM_REF && TREE_CODE (rhs1) == SSA_NAME)
|
||||||
|
{
|
||||||
|
- /* MEM[(long int *)a_1] = _57. */
|
||||||
|
+ /* add such as: MEM[(long int *)a_1] = _1. */
|
||||||
|
if (rhs1 == current_node)
|
||||||
|
{
|
||||||
|
res = add_node (TREE_OPERAND (lhs, 0),
|
||||||
|
@@ -3097,7 +3097,8 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
isptrptr (TREE_TYPE (rhs)) ? TREE_TYPE (rhs) : NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- /* void * _1; struct arc * _2;
|
||||||
|
+ /* find void ssa_name such as:
|
||||||
|
+ void * _1; struct arc * _2;
|
||||||
|
_2 = _1 + _3; _1 = calloc (100, 40). */
|
||||||
|
if (TREE_CODE (rhs) == SSA_NAME
|
||||||
|
&& VOID_POINTER_P (TREE_TYPE (rhs))
|
||||||
|
@@ -3126,7 +3127,7 @@ ipa_struct_reorg::find_vars (gimple *stmt)
|
||||||
|
find_var (gimple_assign_rhs1 (stmt), stmt);
|
||||||
|
find_var (gimple_assign_rhs2 (stmt), stmt);
|
||||||
|
}
|
||||||
|
- /* _23 = _21 - old_arcs_12. */
|
||||||
|
+ /* find void ssa_name from stmt such as: _2 = _1 - old_arcs_1. */
|
||||||
|
else if ((current_mode == STRUCT_REORDER_FIELDS)
|
||||||
|
&& gimple_assign_rhs_code (stmt) == POINTER_DIFF_EXPR
|
||||||
|
&& types_compatible_p (
|
||||||
|
@@ -3310,7 +3311,7 @@ trace_calculate_negate (gimple *size_def_stmt, tree *num, tree struct_size)
|
||||||
|
{
|
||||||
|
gcc_assert (gimple_assign_rhs_code (size_def_stmt) == NEGATE_EXPR);
|
||||||
|
|
||||||
|
- /* _480 = -_479; _479 = _478 * 72. */
|
||||||
|
+ /* support NEGATE_EXPR trace: _3 = -_2; _2 = _1 * 72. */
|
||||||
|
tree num1 = NULL_TREE;
|
||||||
|
tree arg0 = gimple_assign_rhs1 (size_def_stmt);
|
||||||
|
if (!is_result_of_mult (arg0, &num1, struct_size) || num1 == NULL_TREE)
|
||||||
|
@@ -3329,7 +3330,8 @@ trace_calculate_diff (gimple *size_def_stmt, tree *num)
|
||||||
|
{
|
||||||
|
gcc_assert (gimple_assign_rhs_code (size_def_stmt) == NOP_EXPR);
|
||||||
|
|
||||||
|
- /* _25 = (long unsigned int) _23; _23 = _21 - old_arcs_12. */
|
||||||
|
+ /* support POINTER_DIFF_EXPR trace:
|
||||||
|
+ _3 = (long unsigned int) _2; _2 = _1 - old_arcs_1. */
|
||||||
|
tree arg = gimple_assign_rhs1 (size_def_stmt);
|
||||||
|
size_def_stmt = SSA_NAME_DEF_STMT (arg);
|
||||||
|
if (size_def_stmt && is_gimple_assign (size_def_stmt)
|
||||||
|
@@ -3811,8 +3813,8 @@ ipa_struct_reorg::get_type_field (tree expr, tree &base, bool &indirect,
|
||||||
|
release INTEGER_TYPE cast to struct pointer.
|
||||||
|
(If t has escpaed above, then directly returns
|
||||||
|
and doesn't mark escape follow.). */
|
||||||
|
- /* _607 = MEM[(struct arc_t * *)pl_100].
|
||||||
|
- then base pl_100:ssa_name - pointer_type - integer_type. */
|
||||||
|
+ /* _1 = MEM[(struct arc_t * *)a_1].
|
||||||
|
+ then base a_1: ssa_name - pointer_type - integer_type. */
|
||||||
|
if (current_mode == STRUCT_REORDER_FIELDS)
|
||||||
|
{
|
||||||
|
bool is_int_ptr = POINTER_TYPE_P (TREE_TYPE (base))
|
||||||
|
@@ -4520,8 +4522,15 @@ ipa_struct_reorg::check_ptr_layers (tree a_expr, tree b_expr, gimple* stmt)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- a->type->mark_escape (escape_cast_another_ptr, stmt);
|
||||||
|
- b->type->mark_escape (escape_cast_another_ptr, stmt);
|
||||||
|
+
|
||||||
|
+ if (a)
|
||||||
|
+ {
|
||||||
|
+ a->type->mark_escape (escape_cast_another_ptr, stmt);
|
||||||
|
+ }
|
||||||
|
+ if (b)
|
||||||
|
+ {
|
||||||
|
+ b->type->mark_escape (escape_cast_another_ptr, stmt);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -5649,9 +5658,9 @@ ipa_struct_reorg::rewrite_expr (tree expr, tree newexpr[max_split], bool ignore_
|
||||||
|
if (current_mode == STRUCT_REORDER_FIELDS)
|
||||||
|
{
|
||||||
|
/* Supports the MEM_REF offset.
|
||||||
|
- _1 = MEM[(struct arc *)ap_4 + 72B].flow;
|
||||||
|
- Old rewrite:_1 = ap.reorder.0_8->flow;
|
||||||
|
- New rewrite:_1
|
||||||
|
+ _1 = MEM[(struct arc *)ap_1 + 72B].flow;
|
||||||
|
+ Old rewrite: _1 = ap.reorder.0_8->flow;
|
||||||
|
+ New rewrite: _1
|
||||||
|
= MEM[(struct arc.reorder.0 *)ap.reorder.0_8 + 64B].flow;
|
||||||
|
*/
|
||||||
|
HOST_WIDE_INT offset_tmp = 0;
|
||||||
|
@@ -6150,10 +6159,10 @@ ipa_struct_reorg::rewrite_cond (gcond *stmt, gimple_stmt_iterator *gsi)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* Old rewrite:if (x_1 != 0B)
|
||||||
|
+ /* Old rewrite: if (x_1 != 0B)
|
||||||
|
-> _1 = x.reorder.0_1 != 0B; if (_1 != 1)
|
||||||
|
The logic is incorrect.
|
||||||
|
- New rewrite:if (x_1 != 0B)
|
||||||
|
+ New rewrite: if (x_1 != 0B)
|
||||||
|
-> if (x.reorder.0_1 != 0B);*/
|
||||||
|
for (unsigned i = 0; i < max_split && (newlhs[i] || newrhs[i]); i++)
|
||||||
|
{
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c b/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000000..a5477dcc9be
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/struct/rf_check_ptr_layers_bug.c
|
||||||
|
@@ -0,0 +1,24 @@
|
||||||
|
+/* check_ptr_layers bugfix.*/
|
||||||
|
+/* { dg-do compile } */
|
||||||
|
+struct {
|
||||||
|
+ char a;
|
||||||
|
+} **b = 0, *e = 0;
|
||||||
|
+long c;
|
||||||
|
+char d = 9;
|
||||||
|
+int f;
|
||||||
|
+
|
||||||
|
+void g()
|
||||||
|
+{
|
||||||
|
+ for (; f;)
|
||||||
|
+ if (c)
|
||||||
|
+ (*e).a++;
|
||||||
|
+ if (!d)
|
||||||
|
+ for (;;)
|
||||||
|
+ b &&c;
|
||||||
|
+}
|
||||||
|
+int
|
||||||
|
+main()
|
||||||
|
+{
|
||||||
|
+ g();
|
||||||
|
+}
|
||||||
|
+/* { dg-final { scan-ipa-dump "No structures to transform." "reorder_fields" } } */
|
||||||
|
\ No newline at end of file
|
||||||
|
--
|
||||||
|
2.21.0.windows.1
|
||||||
|
|
||||||
28
gcc.spec
28
gcc.spec
@ -1,4 +1,4 @@
|
|||||||
%global DATE 20210728
|
%global DATE 20210819
|
||||||
|
|
||||||
%global gcc_version 10.3.1
|
%global gcc_version 10.3.1
|
||||||
%global gcc_major 10.3.1
|
%global gcc_major 10.3.1
|
||||||
@ -59,7 +59,7 @@
|
|||||||
Summary: Various compilers (C, C++, Objective-C, ...)
|
Summary: Various compilers (C, C++, Objective-C, ...)
|
||||||
Name: gcc
|
Name: gcc
|
||||||
Version: %{gcc_version}
|
Version: %{gcc_version}
|
||||||
Release: %{DATE}.2
|
Release: %{DATE}.3
|
||||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
|
||||||
URL: https://gcc.gnu.org
|
URL: https://gcc.gnu.org
|
||||||
|
|
||||||
@ -127,6 +127,15 @@ Patch10: 0010-Backport-tree-optimization-94963-avoid-bogus-uninit-.patch
|
|||||||
Patch11: 0011-simdmath-Enable-64-bits-simd-when-test-simd_pcs_attr.patch
|
Patch11: 0011-simdmath-Enable-64-bits-simd-when-test-simd_pcs_attr.patch
|
||||||
Patch12: 0012-fp-model-Enable-fp-model-on-kunpeng.patch
|
Patch12: 0012-fp-model-Enable-fp-model-on-kunpeng.patch
|
||||||
Patch13: 0013-LoopElim-Redundant-loop-elimination-optimization.patch
|
Patch13: 0013-LoopElim-Redundant-loop-elimination-optimization.patch
|
||||||
|
Patch14: 0014-Backport-StructReorg-Structure-reorganization-optimi.patch
|
||||||
|
Patch15: 0015-CompleteStructReorg-Complete-Structure-Reorganizatio.patch
|
||||||
|
Patch16: 0016-StructReorg-Bugfix-in-certain-scenarios.patch
|
||||||
|
Patch17: 0017-mcmodel-Enable-mcmodel-medium-on-kunpeng.patch
|
||||||
|
Patch18: 0018-StructReorderFields-Structure-reorder-fields.patch
|
||||||
|
Patch19: 0019-StructReorderFields-Fix-bugs-and-improve-mechanism.patch
|
||||||
|
Patch20: 0020-Backport-vect-Fix-an-ICE-in-vect_recog_mask_conversi.patch
|
||||||
|
Patch21: 0021-mcmodel-Bugfix-for-mcmodel-medium-on-x86.patch
|
||||||
|
Patch22: 0022-StructReorderFields-Fix-pointer-layer-check-bug.patch
|
||||||
|
|
||||||
%global gcc_target_platform %{_arch}-linux-gnu
|
%global gcc_target_platform %{_arch}-linux-gnu
|
||||||
|
|
||||||
@ -581,6 +590,15 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
|||||||
%patch11 -p1
|
%patch11 -p1
|
||||||
%patch12 -p1
|
%patch12 -p1
|
||||||
%patch13 -p1
|
%patch13 -p1
|
||||||
|
%patch14 -p1
|
||||||
|
%patch15 -p1
|
||||||
|
%patch16 -p1
|
||||||
|
%patch17 -p1
|
||||||
|
%patch18 -p1
|
||||||
|
%patch19 -p1
|
||||||
|
%patch20 -p1
|
||||||
|
%patch21 -p1
|
||||||
|
%patch22 -p1
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -2546,6 +2564,12 @@ end
|
|||||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 19 2021 eastb233 <xiezhiheng@huawei.com> - 10.3.1-20210819.3
|
||||||
|
- Type:Sync
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Sync patch from openeuler/gcc
|
||||||
|
|
||||||
* Wed Jul 28 2021 eastb233 <xiezhiheng@huawei.com> - 10.3.0-20210728.2
|
* Wed Jul 28 2021 eastb233 <xiezhiheng@huawei.com> - 10.3.0-20210728.2
|
||||||
- Type:Sync
|
- Type:Sync
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user