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 r13-3370] tree-optimization/106781 - adjust cgraph lhs removal Date: Wed, 19 Oct 2022 08:56:00 +0000 (GMT) [thread overview] Message-ID: <20221019085600.6197C3857377@sourceware.org> (raw) https://gcc.gnu.org/g:32ab9238d86dfa6d74d3592bec570f4f257d0413 commit r13-3370-g32ab9238d86dfa6d74d3592bec570f4f257d0413 Author: Richard Biener <rguenther@suse.de> Date: Wed Oct 19 09:01:56 2022 +0200 tree-optimization/106781 - adjust cgraph lhs removal The following matches up the cgraph code removing LHS of a noreturn call with what fixup_noreturn_call does which gets along without inserting a definition, fixing the ICE resulting from having no place to actually insert that new def. PR tree-optimization/106781 * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee): Copy LHS removal from fixup_noreturn_call. * gcc.dg/pr106781.c: New testcase. Diff: --- gcc/cgraph.cc | 14 ++++++-------- gcc/testsuite/gcc.dg/pr106781.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index 0417b059965..5851b2ffc6c 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -1411,7 +1411,6 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e) { tree decl = gimple_call_fndecl (e->call_stmt); gcall *new_stmt; - gimple_stmt_iterator gsi; if (e->speculative) { @@ -1572,18 +1571,17 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e) && (VOID_TYPE_P (TREE_TYPE (gimple_call_fntype (new_stmt))) || should_remove_lhs_p (lhs))) { + gimple_call_set_lhs (new_stmt, NULL_TREE); + /* We need to fix up the SSA name to avoid checking errors. */ if (TREE_CODE (lhs) == SSA_NAME) { tree var = create_tmp_reg_fn (DECL_STRUCT_FUNCTION (e->caller->decl), TREE_TYPE (lhs), NULL); - var = get_or_create_ssa_default_def - (DECL_STRUCT_FUNCTION (e->caller->decl), var); - gimple *set_stmt = gimple_build_assign (lhs, var); - gsi = gsi_for_stmt (new_stmt); - gsi_insert_before_without_update (&gsi, set_stmt, GSI_SAME_STMT); - update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), set_stmt); + SET_SSA_NAME_VAR_OR_IDENTIFIER (lhs, var); + SSA_NAME_DEF_STMT (lhs) = gimple_build_nop (); + set_ssa_default_def (DECL_STRUCT_FUNCTION (e->caller->decl), + var, lhs); } - gimple_call_set_lhs (new_stmt, NULL_TREE); update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); } diff --git a/gcc/testsuite/gcc.dg/pr106781.c b/gcc/testsuite/gcc.dg/pr106781.c new file mode 100644 index 00000000000..339c28c41df --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106781.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-div-by-zero" } */ + +int n; + +__attribute__ ((noinline, returns_twice)) static int +bar (int) +{ + n /= 0; + + return n; +} + +int +foo (int x) +{ + return bar (x); +}
reply other threads:[~2022-10-19 8:56 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=20221019085600.6197C3857377@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).