Patchwork Fix PR58532

login
register
mail settings
Submitter Richard Guenther
Date Sept. 30, 2013, 7:36 a.m.
Message ID <alpine.LNX.2.00.1309300934580.29411@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/278934/
State New
Headers show

Comments

Richard Guenther - Sept. 30, 2013, 7:36 a.m.
This fixes PR58532, a bootstrap-debug issue with -O3.  Debug stmts
got in the way of adding abnormal edges during inlining.

Bootstrapped on x86_64-unkown-linux-gnu (with -O3 and default flags),
committed to trunk.

Richard.

2013-09-30  Richard Biener  <rguenther@suse.de>

	PR middle-end/58532
	* tree-cfg.c (make_abnormal_goto_edges): Skip debug statements
	before looking for setjmp-like calls.

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

Patch

Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 202971)
+++ gcc/tree-cfg.c	(working copy)
@@ -1013,6 +1013,9 @@  make_abnormal_goto_edges (basic_block bb
 	      break;
 	    }
 	}
+      if (!gsi_end_p (gsi)
+	  && is_gimple_debug (gsi_stmt (gsi)))
+	gsi_next_nondebug (&gsi);
       if (!gsi_end_p (gsi))
 	{
 	  /* Make an edge to every setjmp-like call.  */
Index: gcc/testsuite/g++.dg/torture/pr58552.C
===================================================================
--- gcc/testsuite/g++.dg/torture/pr58552.C	(revision 0)
+++ gcc/testsuite/g++.dg/torture/pr58552.C	(working copy)
@@ -0,0 +1,29 @@ 
+// { dg-do compile }
+// { dg-additional-options "-fcompare-debug" }
+
+extern void fancy_abort () __attribute__ ((__noreturn__));
+extern "C" {
+    struct __jmp_buf_tag { };
+    typedef struct __jmp_buf_tag jmp_buf[1];
+    extern int _setjmp (struct __jmp_buf_tag __env[1]) throw ();
+}
+extern void *gfc_state_stack;
+static jmp_buf eof_buf;
+static void push_state ()
+{
+  if (!gfc_state_stack)
+    fancy_abort ();
+}
+bool gfc_parse_file (void)
+{
+  int seen_program=0;
+  if (_setjmp (eof_buf))
+    return false;
+  if (seen_program)
+    goto duplicate_main;
+  seen_program = 1;
+  push_state ();
+  push_state ();
+duplicate_main:
+  return true;
+}