aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-05-04 13:12:02 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-05-04 13:12:02 +0000
commit27c2cfa6992fb85f5705f918424b16cf1089a4b8 (patch)
tree6e4188a7f3108777ae02378556abaec21d9a9f03
parent9c265c4d12bbf2dae3f42d63313db971993f1237 (diff)
downloadgcc-27c2cfa6992fb85f5705f918424b16cf1089a4b8.zip
gcc-27c2cfa6992fb85f5705f918424b16cf1089a4b8.tar.gz
gcc-27c2cfa6992fb85f5705f918424b16cf1089a4b8.tar.bz2
re PR tree-optimization/43879 (-fipa-pta causes various miscompilations)
2010-05-04 Richard Guenther <rguenther@suse.de> PR tree-optimization/43879 * tree-ssa-structalias.c (alias_get_name): Use DECL_ASSEMBLER_NAME if available. (create_function_info_for): Return the varinfo node. (ipa_pta_execute): Associate same-body aliases and extra names with their origin nodes varinfo. Dump DECL_ASSEMBLER_NAME. * g++.dg/torture/pr43879-1_0.C: New testcase. * g++.dg/torture/pr43879-1_1.C: Likewise. From-SVN: r159026
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/torture/pr43879-1_0.C11
-rw-r--r--gcc/testsuite/g++.dg/torture/pr43879-1_1.C48
-rw-r--r--gcc/tree-ssa-structalias.c43
5 files changed, 108 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b8c4c18..c7d8620 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-04 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/43879
+ * tree-ssa-structalias.c (alias_get_name): Use
+ DECL_ASSEMBLER_NAME if available.
+ (create_function_info_for): Return the varinfo node.
+ (ipa_pta_execute): Associate same-body aliases and extra names
+ with their origin nodes varinfo. Dump DECL_ASSEMBLER_NAME.
+
2010-05-04 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (sh_small_register_classes_for_mode_p): Remove
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4c7f13d..60ec841 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-04 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/43879
+ * g++.dg/torture/pr43879-1_0.C: New testcase.
+ * g++.dg/torture/pr43879-1_1.C: Likewise.
+
2010-05-03 Dodji Seketeli <dodji@redhat.com>
PR c++/43953
diff --git a/gcc/testsuite/g++.dg/torture/pr43879-1_0.C b/gcc/testsuite/g++.dg/torture/pr43879-1_0.C
new file mode 100644
index 0000000..710f6ad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr43879-1_0.C
@@ -0,0 +1,11 @@
+struct A {
+ int *i;
+ A();
+ ~A();
+};
+
+static int x = 0;
+
+A::A() : i(&x) {}
+A::~A() {}
+
diff --git a/gcc/testsuite/g++.dg/torture/pr43879-1_1.C b/gcc/testsuite/g++.dg/torture/pr43879-1_1.C
new file mode 100644
index 0000000..0c94338
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr43879-1_1.C
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-options "-fipa-pta" } */
+/* { dg-additional-sources "pr43879-1_0.C" } */
+
+struct A {
+ int *i;
+ A();
+ ~A();
+};
+
+static inline int
+aa(int *a, int *b)
+{
+ (void)b;
+ return *a;
+}
+
+struct B {
+ B() : i(0) {}
+ int i;
+ B(const A &a) : i(0)
+ {
+ f(*a.i);
+ }
+ void __attribute__((noinline, noclone))
+ f(int j)
+ {
+ aa(&i, &j);
+ i = 1;
+ }
+};
+
+int
+test()
+{
+ B b1;
+ B b2 = B(A());
+ b1 = B(A());
+ if (b1.i != b2.i) __builtin_abort();
+ return 0;
+}
+
+int
+main()
+{
+ return test();
+}
+
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 89b5c9c..f688d9b 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -2759,10 +2759,14 @@ lookup_vi_for_tree (tree t)
static const char *
alias_get_name (tree decl)
{
- const char *res = get_name (decl);
+ const char *res;
char *temp;
int num_printed = 0;
+ if (DECL_ASSEMBLER_NAME_SET_P (decl))
+ res = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+ else
+ res= get_name (decl);
if (res != NULL)
return res;
@@ -4956,7 +4960,7 @@ count_num_arguments (tree decl, bool *is_varargs)
/* Creation function node for DECL, using NAME, and return the index
of the variable we've created for the function. */
-static unsigned int
+static varinfo_t
create_function_info_for (tree decl, const char *name)
{
struct function *fn = DECL_STRUCT_FUNCTION (decl);
@@ -5129,7 +5133,7 @@ create_function_info_for (tree decl, const char *name)
prev_vi = argvi;
}
- return vi->id;
+ return vi;
}
@@ -6565,6 +6569,9 @@ ipa_pta_execute (void)
/* Build the constraints. */
for (node = cgraph_nodes; node; node = node->next)
{
+ struct cgraph_node *alias;
+ varinfo_t vi;
+
/* Nodes without a body are not interesting. Especially do not
visit clones at this point for now - we get duplicate decls
there for inline clones at least. */
@@ -6572,13 +6579,26 @@ ipa_pta_execute (void)
|| node->clone_of)
continue;
- create_function_info_for (node->decl,
- cgraph_node_name (node));
+ vi = create_function_info_for (node->decl,
+ alias_get_name (node->decl));
+
+ /* Associate the varinfo node with all aliases. */
+ for (alias = node->same_body; alias; alias = alias->next)
+ insert_vi_for_tree (alias->decl, vi);
}
/* Create constraints for global variables and their initializers. */
for (var = varpool_nodes; var; var = var->next)
- get_vi_for_tree (var->decl);
+ {
+ struct varpool_node *alias;
+ varinfo_t vi;
+
+ vi = get_vi_for_tree (var->decl);
+
+ /* Associate the varinfo node with all aliases. */
+ for (alias = var->extra_name; alias; alias = alias->next)
+ insert_vi_for_tree (alias->decl, vi);
+ }
if (dump_file)
{
@@ -6601,9 +6621,14 @@ ipa_pta_execute (void)
continue;
if (dump_file)
- fprintf (dump_file,
- "Generating constraints for %s\n",
- cgraph_node_name (node));
+ {
+ fprintf (dump_file,
+ "Generating constraints for %s", cgraph_node_name (node));
+ if (DECL_ASSEMBLER_NAME_SET_P (node->decl))
+ fprintf (dump_file, " (%s)",
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (node->decl)));
+ fprintf (dump_file, "\n");
+ }
func = DECL_STRUCT_FUNCTION (node->decl);
old_func_decl = current_function_decl;