Commit 1e211590 by David Daney Committed by David Daney

re PR rtl-optimization/40445 (g++ void f() { __builtin_unreachable(); })

2009-07-25  David Daney  <ddaney@caviumnetworks.com>

	PR rtl-optimization/40445
	* emit-rtl.c (next_nonnote_insn_bb): New function.
	* rtl.h (next_nonnote_insn_bb): Declare new function.
	* cfgcleanup.c (try_optimize_cfg): Don't remove an empty block
	with no successors that is the successor of the ENTRY_BLOCK.
	Continue from the top after removing an empty fallthrough block.
	* cfgrtl.c (get_last_bb_insn): Call next_nonnote_insn_bb instead
	of next_nonnote_insn.

2009-07-25  David Daney  <ddaney@caviumnetworks.com>

	PR rtl-optimization/40445
	* g++.dg/other/builtin-unreachable-1.C: New testcase.

From-SVN: r150090
parent ba21aba3
2009-07-25 David Daney <ddaney@caviumnetworks.com> 2009-07-25 David Daney <ddaney@caviumnetworks.com>
PR rtl-optimization/40445
* emit-rtl.c (next_nonnote_insn_bb): New function.
* rtl.h (next_nonnote_insn_bb): Declare new function.
* cfgcleanup.c (try_optimize_cfg): Don't remove an empty block
with no successors that is the successor of the ENTRY_BLOCK.
Continue from the top after removing an empty fallthrough block.
* cfgrtl.c (get_last_bb_insn): Call next_nonnote_insn_bb instead
of next_nonnote_insn.
2009-07-25 David Daney <ddaney@caviumnetworks.com>
* cfgcleanup.c (old_insns_match_p): Handle the case of empty * cfgcleanup.c (old_insns_match_p): Handle the case of empty
blocks. blocks.
......
...@@ -1846,10 +1846,16 @@ try_optimize_cfg (int mode) ...@@ -1846,10 +1846,16 @@ try_optimize_cfg (int mode)
/* Delete trivially dead basic blocks. This is either /* Delete trivially dead basic blocks. This is either
blocks with no predecessors, or empty blocks with no blocks with no predecessors, or empty blocks with no
successors. Empty blocks may result from expanding successors. However if the empty block with no
successors is the successor of the ENTRY_BLOCK, it is
kept. This ensures that the ENTRY_BLOCK will have a
successor which is a precondition for many RTL
passes. Empty blocks may result from expanding
__builtin_unreachable (). */ __builtin_unreachable (). */
if (EDGE_COUNT (b->preds) == 0 if (EDGE_COUNT (b->preds) == 0
|| (EDGE_COUNT (b->succs) == 0 && BB_HEAD (b) == BB_END (b))) || (EDGE_COUNT (b->succs) == 0
&& BB_HEAD (b) == BB_END (b)
&& single_succ_edge (ENTRY_BLOCK_PTR)->dest != b))
{ {
c = b->prev_bb; c = b->prev_bb;
if (dump_file) if (dump_file)
...@@ -1921,6 +1927,7 @@ try_optimize_cfg (int mode) ...@@ -1921,6 +1927,7 @@ try_optimize_cfg (int mode)
delete_basic_block (b); delete_basic_block (b);
changed = true; changed = true;
b = c; b = c;
continue;
} }
if (single_succ_p (b) if (single_succ_p (b)
......
...@@ -1712,11 +1712,11 @@ get_last_bb_insn (basic_block bb) ...@@ -1712,11 +1712,11 @@ get_last_bb_insn (basic_block bb)
end = tmp; end = tmp;
/* Include any barriers that may follow the basic block. */ /* Include any barriers that may follow the basic block. */
tmp = next_nonnote_insn (end); tmp = next_nonnote_insn_bb (end);
while (tmp && BARRIER_P (tmp)) while (tmp && BARRIER_P (tmp))
{ {
end = tmp; end = tmp;
tmp = next_nonnote_insn (end); tmp = next_nonnote_insn_bb (end);
} }
return end; return end;
......
...@@ -2998,6 +2998,25 @@ next_nonnote_insn (rtx insn) ...@@ -2998,6 +2998,25 @@ next_nonnote_insn (rtx insn)
return insn; return insn;
} }
/* Return the next insn after INSN that is not a NOTE, but stop the
search before we enter another basic block. This routine does not
look inside SEQUENCEs. */
rtx
next_nonnote_insn_bb (rtx insn)
{
while (insn)
{
insn = NEXT_INSN (insn);
if (insn == 0 || !NOTE_P (insn))
break;
if (NOTE_INSN_BASIC_BLOCK_P (insn))
return NULL_RTX;
}
return insn;
}
/* Return the previous insn before INSN that is not a NOTE. This routine does /* Return the previous insn before INSN that is not a NOTE. This routine does
not look inside SEQUENCEs. */ not look inside SEQUENCEs. */
......
...@@ -1626,6 +1626,7 @@ extern rtx previous_insn (rtx); ...@@ -1626,6 +1626,7 @@ extern rtx previous_insn (rtx);
extern rtx next_insn (rtx); extern rtx next_insn (rtx);
extern rtx prev_nonnote_insn (rtx); extern rtx prev_nonnote_insn (rtx);
extern rtx next_nonnote_insn (rtx); extern rtx next_nonnote_insn (rtx);
extern rtx next_nonnote_insn_bb (rtx);
extern rtx prev_real_insn (rtx); extern rtx prev_real_insn (rtx);
extern rtx next_real_insn (rtx); extern rtx next_real_insn (rtx);
extern rtx prev_active_insn (rtx); extern rtx prev_active_insn (rtx);
......
2009-07-25 David Daney <ddaney@caviumnetworks.com> 2009-07-25 David Daney <ddaney@caviumnetworks.com>
PR rtl-optimization/40445
* g++.dg/other/builtin-unreachable-1.C: New testcase.
2009-07-25 David Daney <ddaney@caviumnetworks.com>
* gcc.dg/builtin-unreachable-4.c: New test. * gcc.dg/builtin-unreachable-4.c: New test.
2009-07-25 Tobias Burnus <burnus@net-b.de> 2009-07-25 Tobias Burnus <burnus@net-b.de>
......
// PR c++/40445
// Check that a function containing only __builtin_unreachable()
// doesn't ICE.
// { dg-do compile }
// { dg-options "-O0" }
const char *
f (void)
{
__builtin_unreachable ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment