]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/24117 (struct is not marked fully as call clobbered)
authorDaniel Berlin <dberlin@dberlin.org>
Thu, 29 Sep 2005 19:38:00 +0000 (19:38 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Thu, 29 Sep 2005 19:38:00 +0000 (19:38 +0000)
2005-09-29  Daniel Berlin  <dberlin@dberlin.org>

Fix PR tree-optimization/24117
* tree-ssa-structalias.c (find_func_aliases): Strip nops
before considering whether to use anyoffset.

From-SVN: r104791

gcc/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr24117.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index ebedfcacf59dcb806d1435ec52ce8127a6aa7c1e..2242dcdf8cd12e573a0ec91da50bf5d48e59d42b 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-29  Daniel Berlin  <dberlin@dberlin.org>
+       
+       Fix PR tree-optimization/24117
+       * tree-ssa-structalias.c (find_func_aliases): Strip nops
+       before considering whether to use anyoffset.
+
 2005-09-29  Paolo Bonzini  <bonzini@gnu.org>
 
        Revert this patch:
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr24117.c b/gcc/testsuite/gcc.dg/tree-ssa/pr24117.c
new file mode 100644 (file)
index 0000000..ffa5dd0
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+typedef struct  {
+  int x;
+  int z;
+} Foo_t;
+
+char *xm;
+void bar(void);
+
+void foo(void)
+{
+  Foo_t x;
+  x.x = 1;
+  x.z = 2;
+  xm = (char *)&x;
+  bar();
+  /* We can't propagate x.z past bar, so this link_error should still be there.  */
+  if (x.z != 2)
+    link_error ();
+}
+/* { dg-final { scan-tree-dump-times "link_error" 1 "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index c41519ca8463cc81e85619e33b539c0656f46b54..890006afd2094ded167af56e1d13459c9b42c4e9 100644 (file)
@@ -2817,16 +2817,18 @@ find_func_aliases (tree t, struct alias_info *ai)
                  case tcc_expression:
                  case tcc_unary:
                      {
+                       tree anyoffsetrhs = rhsop;
                        bool need_anyoffset = false;
                        rhs = get_constraint_for (rhsop, &need_anyoffset);
                        process_constraint (new_constraint (lhs, rhs));
-
+                       
+                       STRIP_NOPS (anyoffsetrhs);
                        /* When taking the address of an aggregate
                           type, from the LHS we can access any field
                           of the RHS.  */
                        if (need_anyoffset || (rhs.type == ADDRESSOF
                            && !(get_varinfo (rhs.var)->is_special_var)
-                           && AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (rhsop)))))
+                           && AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (anyoffsetrhs)))))
                          {
                            rhs.var = anyoffset_id;
                            rhs.type = ADDRESSOF;