Fix for PR39557
authordavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 17:20:51 +0000 (17:20 +0000)
committerdavidxl <davidxl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 17:20:51 +0000 (17:20 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145119 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 3b91d91..9ca01a2 100644 (file)
@@ -1,5 +1,10 @@
 2009-03-27  Xinliang David Li  <davidxl@google.com>
 
+       PR tree-optimization/39557
+       * tree-ssa.c (warn_uninitialized_vars): free postdom info.
+
+2009-03-27  Xinliang David Li  <davidxl@google.com>
+
        PR tree-optimization/39548
        * tree-ssa-copy.c (copy_prop_visit_phi_node): Add copy 
        candidate check.
index 4b64a98..38567f6 100644 (file)
@@ -1,5 +1,10 @@
 2009-03-27  Xinliang David Li  <davidxl@google.com>
 
+       PR tree-optimization/39557
+       * g++.dg/tree-ssa/dom-invalid.C: New test.
+
+2009-03-27  Xinliang David Li  <davidxl@google.com>
+
        PR tree-optimization/39548
        * g++.dg/tree-ssa/copyprop.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
new file mode 100644 (file)
index 0000000..5513d36
--- /dev/null
@@ -0,0 +1,52 @@
+// PR tree-optimization/39557
+// invalid post-dom info leads to infinite loop
+// { dg-do run }
+// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fno-rtti" }
+
+struct C
+{
+ virtual const char *bar () const;
+};
+
+struct D
+{
+ D () : d1 (0) { }
+ C *d2[4];
+ int d1;
+ inline const C & baz (int i) const { return *d2[i]; }
+};
+
+struct E
+{
+ unsigned char e1[2];
+ D e2;
+ bool foo () const { return (e1[1] & 1) != 0; }
+ virtual const char *bar () const __attribute__ ((noinline));
+};
+
+const char *
+C::bar () const
+{
+ return 0;
+}
+
+C c;
+
+const char *
+E::bar () const
+{
+ const char *e = __null;
+ if (foo () && (e = c.C::bar ()))
+   return e;
+ for (int i = 0, n = e2.d1; i < n; i++)
+   if ((e = e2.baz (i).C::bar ()))
+     return e;
+ return e;
+}
+
+int
+main ()
+{
+ E e;
+ e.bar ();
+} // { dg-message  "note: file" "" }
index b26884b..8be2961 100644 (file)
@@ -1589,6 +1589,11 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
          walk_gimple_op (gsi_stmt (gsi), warn_uninitialized_var, &wi);
        }
     }
+
+  /* Post-dominator information can not be reliably updated. Free it
+     after the use.  */
+
+  free_dominance_info (CDI_POST_DOMINATORS);
   return 0;
 }