aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-10-01 09:49:49 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2024-10-01 09:49:49 +0200
commitbdbd0607d5933cdecbf7e009a42f1d9486dddf44 (patch)
tree52ece0071c558397717a8882e11e963267cac49d
parent0939c8ca2fec3f4d8b6ad35da653d75412870357 (diff)
downloadgcc-bdbd0607d5933cdecbf7e009a42f1d9486dddf44.zip
gcc-bdbd0607d5933cdecbf7e009a42f1d9486dddf44.tar.gz
gcc-bdbd0607d5933cdecbf7e009a42f1d9486dddf44.tar.bz2
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 <jakub@redhat.com> 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.
-rw-r--r--gcc/gimple-range-cache.cc9
-rw-r--r--gcc/testsuite/gcc.dg/bitint-110.c20
2 files changed, 26 insertions, 3 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 4394989..c0b8916 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1284,13 +1284,16 @@ ranger_cache::block_range (vrange &r, basic_block bb, tree name, bool calc)
gimple *def_stmt = SSA_NAME_DEF_STMT (name);
basic_block def_bb = NULL;
if (def_stmt)
- def_bb = gimple_bb (def_stmt);;
+ def_bb = gimple_bb (def_stmt);
if (!def_bb)
{
// If we get to the entry block, this better be a default def
// or range_on_entry was called for a block not dominated by
- // the def.
- gcc_checking_assert (SSA_NAME_IS_DEFAULT_DEF (name));
+ // the def. But it could be also SSA_NAME defined by a statement
+ // not yet in the IL (such as queued edge insertion), in that case
+ // just punt.
+ if (!SSA_NAME_IS_DEFAULT_DEF (name))
+ return false;
def_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
}
diff --git a/gcc/testsuite/gcc.dg/bitint-110.c b/gcc/testsuite/gcc.dg/bitint-110.c
new file mode 100644
index 0000000..4ba2f93
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-110.c
@@ -0,0 +1,20 @@
+/* PR middle-end/116898 */
+/* { dg-do compile { target bitint575 } } */
+/* { dg-options "-O -finstrument-functions -fnon-call-exceptions" } */
+
+_BitInt(127) a;
+_BitInt(511) b;
+
+void
+foo (_BitInt(31) c)
+{
+ do
+ {
+ c %= b;
+again:
+ }
+ while (c);
+ a /= 0; /* { dg-warning "division by zero" } */
+ c -= a;
+ goto again;
+}