diff mbox

[1/3] cfgcleanup: Bugfix in try_simplify_condjump

Message ID 2a60ce46242613cda251f7f323e84aa6027d757c.1462256245.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool May 3, 2016, 6:59 a.m. UTC
If the jump_block here contains just a return, we will crash later
in invert_jump.  Don't allow that case.


2016-05-03  Segher Boessenkool  <segher@kernel.crashing.org>

	* cfgcleanup.c (try_simplify_condjump): Don't try to simplify a
	branch to a return.

---
 gcc/cfgcleanup.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steven Bosscher May 3, 2016, 8:28 p.m. UTC | #1
On Tue, May 3, 2016 at 8:59 AM, Segher Boessenkool wrote:
> If the jump_block here contains just a return, we will crash later
> in invert_jump.  Don't allow that case.

But if jump_block contains a return, then it isn't the EXIT_BLOCK for
the function.
Is the conditional jump a conditional return insn?

Ciao!
Steven
Segher Boessenkool May 3, 2016, 9:09 p.m. UTC | #2
On Tue, May 03, 2016 at 10:28:37PM +0200, Steven Bosscher wrote:
> On Tue, May 3, 2016 at 8:59 AM, Segher Boessenkool wrote:
> > If the jump_block here contains just a return, we will crash later
> > in invert_jump.  Don't allow that case.
> 
> But if jump_block contains a return, then it isn't the EXIT_BLOCK for
> the function.

The single successor block of the jump block is the exit block.

Too many blocks here ;-)


Segher
diff mbox

Patch

diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 6e92d4c..19583a7 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -156,6 +156,7 @@  try_simplify_condjump (basic_block cbranch_block)
   cbranch_dest_block = cbranch_jump_edge->dest;
 
   if (cbranch_dest_block == EXIT_BLOCK_PTR_FOR_FN (cfun)
+      || jump_dest_block == EXIT_BLOCK_PTR_FOR_FN (cfun)
       || !can_fallthru (jump_block, cbranch_dest_block))
     return false;