diff mbox

fix segfault in verify_flow_info() with -dx option

Message ID CAAgBjM=+zEhza27H8_n9qYyFE-o8RwnVTNaYL_2v3OppZ1U8Nw@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni July 5, 2015, 12:07 p.m. UTC
Hi,
Passing -dx causes segmentation fault:
Test case: void f(void) {}

./test.c: In function 'f':
../test.c:3:1: internal compiler error: Segmentation fault
 }
 ^
0xab6baf crash_signal
        /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/toplev.c:366
0x694b14 verify_flow_info()
        /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/cfghooks.c:109
0x9f7e64 execute_function_todo
        /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:1997
0x9f86eb execute_todo
        /home/prathamesh.kulkarni/gnu-toolchain/src/gcc.git/gcc/passes.c:2042

Started with r210068.
It looks like -dx causes cfun->cfg to be NULL, and hence the segfault
in verify_flow_info().
The attached patch tries to fix it by adding a check to cfun->cfg before calling
verify_flow_info() from execute_function_todo().
Bootstrapped and tested on x86_64-unknown-linux-gnu.
OK for trunk ?

Thank you,
Prathamesh
2015-07-05  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	* passes.c (execute_function_todo): Check for cfun->cfg before calling verify_flow_info().
diff mbox

Patch

diff --git a/gcc/passes.c b/gcc/passes.c
index 4966334..8362554 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1965,7 +1965,8 @@  execute_function_todo (function *fn, void *data)
 	  /* IPA passes leave basic-blocks unsplit, so make sure to
 	     not trip on that.  */
 	  if ((cfun->curr_properties & PROP_cfg)
-	      && !from_ipa_pass)
+	      && !from_ipa_pass
+	      && cfun->cfg)
 	    verify_flow_info ();
 	  if (current_loops
 	      && loops_state_satisfies_p (LOOP_CLOSED_SSA))