public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-6120] middle-end/112785 - guard against last_clique overflow Date: Mon, 4 Dec 2023 14:34:17 +0000 (GMT) [thread overview] Message-ID: <20231204143417.4A2EC385782C@sourceware.org> (raw) https://gcc.gnu.org/g:0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2 commit r14-6120-g0c2ea80a4ffbddc0bc29f5badaf2ae43e59483b2 Author: Richard Biener <rguenther@suse.de> Date: Mon Dec 4 14:50:59 2023 +0100 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. Diff: --- 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; }
reply other threads:[~2023-12-04 14:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231204143417.4A2EC385782C@sourceware.org \ --to=rguenth@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).