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-4864] ipa/111914 - perform parameter init after remapping types Date: Mon, 23 Oct 2023 13:33:08 +0000 (GMT) [thread overview] Message-ID: <20231023133308.848E23857C5A@sourceware.org> (raw) https://gcc.gnu.org/g:738d44348e7392a9f8e370afa3a9d8c24ee080cd commit r14-4864-g738d44348e7392a9f8e370afa3a9d8c24ee080cd Author: Richard Biener <rguenther@suse.de> Date: Mon Oct 23 13:29:30 2023 +0200 ipa/111914 - perform parameter init after remapping types The following addresses a mismatch in SSA name vs. symbol when we emit a dummy assignment when not optimizing. The temporary we create is not remapped by initialize_inlined_parameters because we have no easy way to get at it. The following instead emits the additional statement after we have remapped the type of the replacement variable. PR ipa/111914 * tree-inline.cc (setup_one_parameter): Move code emitting a dummy load when not optimizing ... (initialize_inlined_parameters): ... here to after when we remapped the parameter type. * gcc.dg/pr111914.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr111914.c | 14 ++++++++++++++ gcc/tree-inline.cc | 26 ++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr111914.c b/gcc/testsuite/gcc.dg/pr111914.c new file mode 100644 index 000000000000..05804bddcb9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111914.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +__attribute__((always_inline)) +static inline void f(int n, int (*a())[n]) +{ + /* Unused 'a'. */ +} + +void g(void) +{ + int (*a())[1]; + f(1, a); +} diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index d63060c9429c..69387b525f9e 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -3578,9 +3578,7 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, STRIP_USELESS_TYPE_CONVERSION (rhs); - /* If we are in SSA form properly remap the default definition - or assign to a dummy SSA name if the parameter is unused and - we are not optimizing. */ + /* If we are in SSA form properly remap the default definition. */ if (gimple_in_ssa_p (cfun) && is_gimple_reg (p)) { if (def) @@ -3590,11 +3588,6 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, SSA_NAME_IS_DEFAULT_DEF (def) = 0; set_ssa_default_def (cfun, var, NULL); } - else if (!optimize) - { - def = make_ssa_name (var); - init_stmt = gimple_build_assign (def, rhs); - } } else if (!is_empty_type (TREE_TYPE (var))) init_stmt = gimple_build_assign (var, rhs); @@ -3653,6 +3646,23 @@ initialize_inlined_parameters (copy_body_data *id, gimple *stmt, && SSA_NAME_VAR (*defp) == var) TREE_TYPE (*defp) = TREE_TYPE (var); } + /* When not optimizing and the parameter is unused, assign to + a dummy SSA name. Do this after remapping the type above. */ + else if (!optimize + && is_gimple_reg (p) + && i < gimple_call_num_args (stmt)) + { + tree val = gimple_call_arg (stmt, i); + if (val != error_mark_node) + { + if (!useless_type_conversion_p (TREE_TYPE (p), + TREE_TYPE (val))) + val = force_value_to_type (TREE_TYPE (p), val); + def = make_ssa_name (var); + gimple *init_stmt = gimple_build_assign (def, val); + insert_init_stmt (id, bb, init_stmt); + } + } } }
reply other threads:[~2023-10-23 13:33 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=20231023133308.848E23857C5A@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).