aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-12-04 14:50:59 +0100
committerRichard Biener <rguenther@suse.de>2023-12-04 15:33:58 +0100
commit0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2 (patch)
tree3eea2dce78a72ebb27d6791572b485a8f6db7b82 /gcc
parent82576a6e77e0a284975dda87efe4b2d5bc5b9b1c (diff)
downloadgcc-0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2.zip
gcc-0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2.tar.gz
gcc-0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2.tar.bz2
middle-end/112785 - guard against last_clique overflow
The PR shows that we'll ICE eventually when last_clique wraps. The following avoids this by refusing to hand out new cliques after exhausting them. We then use zero (no clique) as conservative fallback. PR middle-end/112785 * function.h (get_new_clique): New inline function handling last_clique overflow. * cfgrtl.cc (duplicate_insn_chain): Use it. * tree-cfg.cc (gimple_duplicate_bb): Likewise. * tree-inline.cc (remap_dependence_clique): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cfgrtl.cc2
-rw-r--r--gcc/function.h11
-rw-r--r--gcc/tree-cfg.cc2
-rw-r--r--gcc/tree-inline.cc2
4 files changed, 14 insertions, 3 deletions
diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc
index abcb472..2a3f853 100644
--- a/gcc/cfgrtl.cc
+++ b/gcc/cfgrtl.cc
@@ -4385,7 +4385,7 @@ duplicate_insn_chain (rtx_insn *from, rtx_insn *to,
{
gcc_assert
(MR_DEPENDENCE_CLIQUE (op) <= cfun->last_clique);
- newc = ++cfun->last_clique;
+ newc = get_new_clique (cfun);
}
/* We cannot adjust MR_DEPENDENCE_CLIQUE in-place
since MEM_EXPR is shared so make a copy and
diff --git a/gcc/function.h b/gcc/function.h
index 2984656..833c35e 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -518,6 +518,17 @@ set_loops_for_fn (struct function *fn, struct loops *loops)
fn->x_current_loops = loops;
}
+/* Get a new unique dependence clique or zero if none is left. */
+
+inline unsigned short
+get_new_clique (function *fn)
+{
+ unsigned short clique = fn->last_clique + 1;
+ if (clique != 0)
+ fn->last_clique = clique;
+ return clique;
+}
+
/* For backward compatibility... eventually these should all go away. */
#define current_function_funcdef_no (cfun->funcdef_no)
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index a30a2de..475ea5d 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -6595,7 +6595,7 @@ gimple_duplicate_bb (basic_block bb, copy_bb_data *id)
if (!existed)
{
gcc_assert (MR_DEPENDENCE_CLIQUE (op) <= cfun->last_clique);
- newc = ++cfun->last_clique;
+ newc = get_new_clique (cfun);
}
MR_DEPENDENCE_CLIQUE (op) = newc;
}
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index e6d55305..a4fc839 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -1002,7 +1002,7 @@ remap_dependence_clique (copy_body_data *id, unsigned short clique)
/* Clique 1 is reserved for local ones set by PTA. */
if (cfun->last_clique == 0)
cfun->last_clique = 1;
- newc = ++cfun->last_clique;
+ newc = get_new_clique (cfun);
}
return newc;
}