From ae761c4536548e9bfa0619430726b249d732279d Mon Sep 17 00:00:00 2001 From: Andy Hutchinson Date: Thu, 12 Nov 2009 02:35:49 +0000 Subject: [PATCH] re PR middle-end/41440 (SEG FAULT in CSE.C caused by bad RTL expansion) PR middle-end/41440 * cfgexpand.c (expand_gimple_basic_block): Append NOP to a fallthru, single successor block, ending with jump created by RTL expander. From-SVN: r154112 --- gcc/ChangeLog | 6 ++++++ gcc/cfgexpand.c | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c9e6e5b55e..7ec401bc0be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-11-11 Andy Hutchinson + + PR middle-end/41440 + * cfgexpand.c (expand_gimple_basic_block): Append NOP to a fallthru, + single successor block, ending with jump created by RTL expander. + 2009-11-11 Jan Hubicka PR middle-end/41729 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index cfb4d17dc20..c9e1f1a3d73 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3220,6 +3220,18 @@ expand_gimple_basic_block (basic_block bb) } } + /* Expanded RTL can create a jump in the last instruction of block. + This later might be assumed to be a jump to successor and break edge insertion. + We need to insert dummy move to prevent this. PR41440. */ + if (single_succ_p (bb) + && (single_succ_edge (bb)->flags & EDGE_FALLTHRU) + && (last = get_last_insn ()) + && JUMP_P (last)) + { + rtx dummy = gen_reg_rtx (SImode); + emit_insn_after_noloc (gen_move_insn (dummy, dummy), last, NULL); + } + do_pending_stack_adjust (); /* Find the block tail. The last insn in the block is the insn