OSDN Git Service

2007-09-18 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Sep 2007 08:46:23 +0000 (08:46 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 18 Sep 2007 08:46:23 +0000 (08:46 +0000)
PR tree-optimization/33340
* tree-ssa-sccvn.c (set_ssa_val_to): Do not set values to
SSA_NAMEs that occur in abnormal PHI nodes.

* g++.dg/torture/pr33340.C: New testcase.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr33340.C [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index d9f37e8..f8a9aff 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-18  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/33340
+       * tree-ssa-sccvn.c (set_ssa_val_to): Do not set values to
+       SSA_NAMEs that occur in abnormal PHI nodes.
+
 2007-09-17  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * tree-cfg.c (is_ctrl_altering_stmt, tree_block_ends_with_call_p):
index a07270a..3437101 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-18  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/33340
+       * g++.dg/torture/pr33340.C: New testcase.
+
 2007-09-18  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/33231
diff --git a/gcc/testsuite/g++.dg/torture/pr33340.C b/gcc/testsuite/g++.dg/torture/pr33340.C
new file mode 100644 (file)
index 0000000..bac8821
--- /dev/null
@@ -0,0 +1,27 @@
+void* operator new(__SIZE_TYPE__, void* __p) { }
+
+struct auto_ptr {
+        int* p;
+        ~auto_ptr() { delete p; }
+};
+
+typedef void* T;
+struct vector {
+        void push_back(const T& __x) {
+                ::new(0) T(__x);
+                insert(__x);
+        }
+        void insert(const T& __x);
+} v;
+
+void g();
+void f() {
+        auto_ptr ap;
+        if (ap.p) {
+                ap.p = new int();
+        }
+        g();
+        int* tmp = ap.p;
+        ap.p = 0;
+        v.push_back(tmp);
+}
index bca0e84..cddd2d1 100644 (file)
@@ -1022,6 +1022,11 @@ set_ssa_val_to (tree from, tree to)
 {
   tree currval;
 
+  if (from != to
+      && TREE_CODE (to) == SSA_NAME
+      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (to))
+    to = from;
+
   /* The only thing we allow as value numbers are VN_TOP, ssa_names
      and invariants.  So assert that here.  */
   gcc_assert (to != NULL_TREE