* [PATCH] middle-end/112785 - guard against last_clique overflow
@ 2023-12-04 14:33 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-12-04 14:33 UTC (permalink / raw)
To: gcc-patches
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.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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.
---
gcc/cfgrtl.cc | 2 +-
gcc/function.h | 11 +++++++++++
gcc/tree-cfg.cc | 2 +-
gcc/tree-inline.cc | 2 +-
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc
index abcb472e2a2..2a3f853eed5 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 29846564bc6..833c35e3da6 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 a30a2de33a1..475ea5d99ef 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 e6d553059e3..a4fc839a22d 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;
}
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-12-04 14:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 14:33 [PATCH] middle-end/112785 - guard against last_clique overflow Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).