From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 7A9BC3858413 for ; Mon, 23 Oct 2023 13:32:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A9BC3858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A9BC3858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698067922; cv=none; b=uhRXqXE/5P7VPK7SZM8cc74+0S5z1EcFpReJe5aqAlbZJ5GnW+91AvLqSwZGN2JGXsAZjFg0k74oeEwYDcdzmvPY6F4bxiBerEafaXlahq4BXpSn4mlTKStiOlD7GMdxRtrAnyekppMrr64L1WoyCY3aJrK7dfC0rdCh1Ny2XoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698067922; c=relaxed/simple; bh=Lpe8mSUa8hYIEYZUEwL3kF1IKLx6FAj0RCxxsELbXnY=; h=Date:From:To:Subject:MIME-Version; b=lrBJ83QCJbG6Kccghqdw1E5wJ28iofAEX3e1AWBND0jDfNRtwtLPOleyrjwxrSlAmIfWz/O22MGou6k4gTSxdGkfJrf9HloAK8BOINQtau6xTF7riwzpevIY+dHfDT9ukZNfkYKwSW/2BwOPRvPJZJ6Gc8LCrOxLiLNaGNCTqD4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 3405D1FE18 for ; Mon, 23 Oct 2023 13:32:00 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id EECE02C8CD for ; Mon, 23 Oct 2023 13:31:59 +0000 (UTC) Date: Mon, 23 Oct 2023 13:32:00 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] ipa/111914 - perform parameter init after remapping types User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out2.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [-0.01 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[149.44.160.134:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; R_SPF_SOFTFAIL(0.60)[~all:c]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; VIOLATED_DIRECT_SPF(3.50)[]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; DMARC_NA(0.20)[suse.de]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -0.01 X-Rspamd-Queue-Id: 3405D1FE18 X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20231023133200.nEOe9Q4b836wwJMjq_mf1_DxtW2gdra_z3t8pKza64o@z> 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 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. --- gcc/testsuite/gcc.dg/pr111914.c | 14 ++++++++++++++ gcc/tree-inline.cc | 26 ++++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr111914.c diff --git a/gcc/testsuite/gcc.dg/pr111914.c b/gcc/testsuite/gcc.dg/pr111914.c new file mode 100644 index 00000000000..05804bddcb9 --- /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 d63060c9429..69387b525f9 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); + } + } } } -- 2.35.3