This is a regression present on the mainline: an assertion is triggered in
commit_one_edge_insertion at expansion time because a BB contains a BARRIER in
its BB_END, which is not valid. expand_gimple_basic_block is supposed to
prevent that from happening, but it doesn't properly handle the sequence:
JUMP
BARRIER
JUMP_TABLE_DATA
BARRIER
that can be generated for a switch construct.
Bootstrapped/regtested on x86_64-suse-linux, applied on mainline as obvious.
2018-09-15 Eric Botcazou <ebotca...@adacore.com>
PR middle-end/86864
* cfgexpand.c (expand_gimple_basic_block): Be prepared for a BARRIER
before and after a JUMP_TABLE_DATA.
2018-09-15 Eric Botcazou <ebotca...@adacore.com>
* gcc.c-torture/compile/20180915-1.c: New test.
--
Eric Botcazou
Index: cfgexpand.c
===================================================================
--- cfgexpand.c (revision 264202)
+++ cfgexpand.c (working copy)
@@ -5810,6 +5810,8 @@ expand_gimple_basic_block (basic_block b
last = PREV_INSN (last);
if (JUMP_TABLE_DATA_P (last))
last = PREV_INSN (PREV_INSN (last));
+ if (BARRIER_P (last))
+ last = PREV_INSN (last);
BB_END (bb) = last;
update_bb_for_insn (bb);
/* PR middle-end/86864 */
/* Testcase by Serge Belyshev <belys...@depni.sinp.msu.ru> */
long a;
void f ();
void g (int b, int c, int d)
{
switch (b)
{
case 42:
case 29:
case 48:
case 40:
case 32:
c = 2;
break;
case 0:
c = 1;
break;
default:
__builtin_unreachable ();
}
if (d || a)
f ();
if (c == 1)
f ();
}