re PR tree-optimization/81900 (GCC trunk miscompiles Perl / __sigsetjmp issue)
authorRichard Biener <rguenther@suse.de>
Mon, 21 Aug 2017 13:18:35 +0000 (13:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 21 Aug 2017 13:18:35 +0000 (13:18 +0000)
2017-08-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/81900
* tree-ssa-pre.c (compute_antic_aux): Properly compute changed
for blocks with abnormal predecessors.
(compute_antic): Do not set visited flag prematurely.

* gcc.dg/torture/pr81900.c: New testcase.

From-SVN: r251226

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr81900.c [new file with mode: 0644]
gcc/tree-ssa-pre.c

index e0dae1503dc2aa0451f1e3c188e16da63a903efb..25b745208a78ce63bae54ee16469fe805b7b43ad 100644 (file)
@@ -1,3 +1,10 @@
+2017-08-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/81900
+       * tree-ssa-pre.c (compute_antic_aux): Properly compute changed
+       for blocks with abnormal predecessors.
+       (compute_antic): Do not set visited flag prematurely.
+
 2017-08-21  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/79883
index 731c812826a626ea9f8bff049f62f0298ab25424..53505ef21f40673e866b07df8535e80ad27ca608 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/81900
+       * gcc.dg/torture/pr81900.c: New testcase.
+
 2017-08-21  Richard Biener  <rguenther@suse.de>
 
        * c-c++-common/asan/global-overflow-1.c: Adjust diagnostic location
diff --git a/gcc/testsuite/gcc.dg/torture/pr81900.c b/gcc/testsuite/gcc.dg/torture/pr81900.c
new file mode 100644 (file)
index 0000000..9e4e8f4
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR/81900 */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+void Perl_croak() __attribute__((noreturn));
+char *Perl_sv_gets();
+void __attribute__((returns_twice)) __sigsetjmp ();
+void a() {
+    __sigsetjmp();
+    char *b;
+    if ((b = Perl_sv_gets()) == 0)
+      Perl_croak("No Perl script found in input\n");
+    if (*b == '#')
+      __asm__("" : : ""("badbad"));
+}
+
+/* Do not elide the test against zero.  */
+/* { dg-final { scan-tree-dump " == 0B" "optimized" } } */
index a6a68cf837213696ea477f4a1c4b481fb7acf3e4..7243cf808f52504c4b80af96dd5147bdbdbbe70b 100644 (file)
@@ -2119,16 +2119,15 @@ static sbitmap has_abnormal_preds;
 static bool
 compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
 {
-  bool changed = false;
   bitmap_set_t S, old, ANTIC_OUT;
   bitmap_iterator bi;
   unsigned int bii;
   edge e;
   edge_iterator ei;
-  bool was_visited = BB_VISITED (block);
 
-  old = ANTIC_OUT = S = NULL;
+  bool changed = ! BB_VISITED (block);
   BB_VISITED (block) = 1;
+  old = ANTIC_OUT = S = NULL;
 
   /* If any edges from predecessors are abnormal, antic_in is empty,
      so do nothing.  */
@@ -2217,7 +2216,7 @@ compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
   /* clean (ANTIC_IN (block)) is defered to after the iteration converged
      because it can cause non-convergence, see for example PR81181.  */
 
-  if (!was_visited || !bitmap_set_equal (old, ANTIC_IN (block)))
+  if (!bitmap_set_equal (old, ANTIC_IN (block)))
     changed = true;
 
  maybe_dump_sets:
@@ -2396,9 +2395,6 @@ compute_antic (void)
        if (e->flags & EDGE_ABNORMAL)
          {
            bitmap_set_bit (has_abnormal_preds, block->index);
-
-           /* We also anticipate nothing.  */
-           BB_VISITED (block) = 1;
            break;
          }