OSDN Git Service

2009-01-27 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jan 2009 10:42:59 +0000 (10:42 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jan 2009 10:42:59 +0000 (10:42 +0000)
PR tree-optimization/38503
* cfgexpand.c (expand_gimple_basic_block): Ignore
GIMPLE_CHANGE_DYNAMIC_TYPE during expansion.
* tree-ssa-structalias.c (set_uids_in_ptset): Do not prune
variables that cannot have TBAA applied.
(compute_points_to_sets): Do not remove GIMPLE_CHANGE_DYNAMIC_TYPE
statements.

* g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143700 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index d2c1f4b..39f89ec 100644 (file)
@@ -1,3 +1,13 @@
+2009-01-27  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/38503
+       * cfgexpand.c (expand_gimple_basic_block): Ignore
+       GIMPLE_CHANGE_DYNAMIC_TYPE during expansion.
+       * tree-ssa-structalias.c (set_uids_in_ptset): Do not prune
+       variables that cannot have TBAA applied.
+       (compute_points_to_sets): Do not remove GIMPLE_CHANGE_DYNAMIC_TYPE
+       statements.
+
 2009-01-27 Uros Bizjak <ubizjak@gmail.com>
 
        PR middle-end/38969
index 6d7fe77..a9a52c4 100644 (file)
@@ -1970,7 +1970,7 @@ expand_gimple_basic_block (basic_block bb)
                    return new_bb;
                }
            }
-         else
+         else if (gimple_code (stmt) != GIMPLE_CHANGE_DYNAMIC_TYPE)
            {
              tree stmt_tree = gimple_to_tree (stmt);
              last = get_last_insn ();
index 9b9f8ed..1ebe503 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-27  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/38503
+       * g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C: New testcase.
+
 2009-01-27 Uros Bizjak <ubizjak@gmail.com>
 
        PR middle-end/38969
diff --git a/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C b/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-placement-new.C
new file mode 100644 (file)
index 0000000..514957b
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wstrict-aliasing" } */
+
+inline void *operator new (__SIZE_TYPE__, void *__p) throw() { return __p; }
+
+struct Y {
+  Y() {}
+  int i;
+};
+
+struct X {
+  X() {}
+  void construct(const Y& y)
+  {
+    new (&m_data[0]) Y(y);
+  }
+  bool initialized;
+  char m_data[sizeof (Y)];
+};
+
+void bar(const X&);
+void foo(Y& y)
+{
+  X x;
+  x.construct(y);
+  x.initialized = true;
+  bar(x);
+}
+
index 8b49556..cae478a 100644 (file)
@@ -4703,7 +4703,8 @@ set_uids_in_ptset (tree ptr, bitmap into, bitmap from, bool is_derefed,
             type-based pruning disabled.  */
          if (vi->is_artificial_var
              || !is_derefed
-             || no_tbaa_pruning)
+             || no_tbaa_pruning
+             || vi->no_tbaa_pruning)
            bitmap_set_bit (into, DECL_UID (vi->decl));
          else
            {
@@ -5496,19 +5497,8 @@ compute_points_to_sets (void)
            find_func_aliases (phi);
        }
 
-      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
-       {
-         gimple stmt = gsi_stmt (gsi);
-
-         find_func_aliases (stmt);
-
-         /* The information in GIMPLE_CHANGE_DYNAMIC_TYPE statements
-            has now been captured, and we can remove them.  */
-         if (gimple_code (stmt) == GIMPLE_CHANGE_DYNAMIC_TYPE)
-           gsi_remove (&gsi, true);
-         else
-           gsi_next (&gsi);
-       }
+      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       find_func_aliases (gsi_stmt (gsi));
     }