Skip to content

Commit bdbd060

Browse files
committed
range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898]
Some passes like the bitint lowering queue some statements on edges and only commit them at the end of the pass. If they use ranger at the same time, the ranger might see such SSA_NAMEs and ICE on those. The following patch instead just punts on them. 2024-10-01 Jakub Jelinek <[email protected]> PR middle-end/116898 * gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead of failing assertion. Formatting fix. * gcc.dg/bitint-110.c: New test.
1 parent 0939c8c commit bdbd060

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

gcc/gimple-range-cache.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,13 +1284,16 @@ ranger_cache::block_range (vrange &r, basic_block bb, tree name, bool calc)
12841284
gimple *def_stmt = SSA_NAME_DEF_STMT (name);
12851285
basic_block def_bb = NULL;
12861286
if (def_stmt)
1287-
def_bb = gimple_bb (def_stmt);;
1287+
def_bb = gimple_bb (def_stmt);
12881288
if (!def_bb)
12891289
{
12901290
// If we get to the entry block, this better be a default def
12911291
// or range_on_entry was called for a block not dominated by
1292-
// the def.
1293-
gcc_checking_assert (SSA_NAME_IS_DEFAULT_DEF (name));
1292+
// the def. But it could be also SSA_NAME defined by a statement
1293+
// not yet in the IL (such as queued edge insertion), in that case
1294+
// just punt.
1295+
if (!SSA_NAME_IS_DEFAULT_DEF (name))
1296+
return false;
12941297
def_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
12951298
}
12961299

gcc/testsuite/gcc.dg/bitint-110.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* PR middle-end/116898 */
2+
/* { dg-do compile { target bitint575 } } */
3+
/* { dg-options "-O -finstrument-functions -fnon-call-exceptions" } */
4+
5+
_BitInt(127) a;
6+
_BitInt(511) b;
7+
8+
void
9+
foo (_BitInt(31) c)
10+
{
11+
do
12+
{
13+
c %= b;
14+
again:
15+
}
16+
while (c);
17+
a /= 0; /* { dg-warning "division by zero" } */
18+
c -= a;
19+
goto again;
20+
}

0 commit comments

Comments
 (0)