Skip to content

Commit 7dd1f9d

Browse files
committed
bitint: Don't move debug stmts from before returns_twice calls [PR114628]
Debug stmts are allowed by the verifier before the returns_twice calls. More importantly, they don't have a lhs, so the current handling of arg_stmts statements to force them on the edges ICEs. The following patch just keeps them where they were before. 2024-04-09 Jakub Jelinek <[email protected]> PR middle-end/114628 * gimple-lower-bitint.cc (gimple_lower_bitint): Keep debug stmts before returns_twice calls as is, don't push them into arg_stmts vector/move to edges. * gcc.dg/bitint-105.c: New test.
1 parent 46c9166 commit 7dd1f9d

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

gcc/gimple-lower-bitint.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7172,8 +7172,13 @@ gimple_lower_bitint (void)
71727172
gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (stmt));
71737173
while (gsi_stmt (gsi) != stmt)
71747174
{
7175-
arg_stmts.safe_push (gsi_stmt (gsi));
7176-
gsi_remove (&gsi, false);
7175+
if (is_gimple_debug (gsi_stmt (gsi)))
7176+
gsi_next (&gsi);
7177+
else
7178+
{
7179+
arg_stmts.safe_push (gsi_stmt (gsi));
7180+
gsi_remove (&gsi, false);
7181+
}
71777182
}
71787183
gimple *g;
71797184
basic_block bb = NULL;

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* PR middle-end/114628 */
2+
/* { dg-do compile { target bitint } } */
3+
/* { dg-options "-O2 -g" } */
4+
5+
int foo (int);
6+
#if __BITINT_MAXWIDTH__ >= 129
7+
__attribute__((returns_twice)) int bar (_BitInt(129) x);
8+
9+
void
10+
baz (int x, _BitInt(129) y)
11+
{
12+
void *q[] = { &&l1, &&l2 };
13+
l2:
14+
x = foo (foo (3));
15+
bar (y);
16+
goto *q[x & 1];
17+
l1:;
18+
}
19+
20+
void
21+
qux (int x, _BitInt(129) y)
22+
{
23+
void *q[] = { &&l1, &&l2 };
24+
l2:
25+
x = foo (foo (3));
26+
bar (y);
27+
l1:;
28+
}
29+
#endif

0 commit comments

Comments
 (0)