From patchwork Thu May 6 07:48:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1474859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FbR1G6CTkz9sRf for ; Thu, 6 May 2021 18:04:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C13E8385783A; Thu, 6 May 2021 08:03:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id A5C59385783A for ; Thu, 6 May 2021 08:03:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A5C59385783A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rguenther@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E9CDEB1AE for ; Thu, 6 May 2021 08:03:54 +0000 (UTC) Date: Thu, 6 May 2021 09:48:00 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix IPA SRA removal of DECL_BY_REFERENCE return Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" While doing bogus call LHS removal I noticed that cloning with dropping a return value creates a bogus replacement for a DECL_BY_REFERENCE DECL_RESULT, resulting in MEM_REFs of aggregates rather than pointers. The following fixes this latent issue. I don't have a testcase that ICEs without doing a bogus DSE transform though. Bootstrap & regtest running on x86_64-unknown-linux-gnu. 2021-05-06 Richard Biener * tree-inline.c (tree_function_versioning): Fix DECL_BY_REFERENCE return variable removal. --- gcc/tree-inline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 49a5850f410..8f945b88c12 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -6367,6 +6367,8 @@ tree_function_versioning (tree old_decl, tree new_decl, tree resdecl_repl = copy_result_decl_to_var (DECL_RESULT (old_decl), &id); declare_inline_vars (NULL, resdecl_repl); + if (DECL_BY_REFERENCE (DECL_RESULT (old_decl))) + resdecl_repl = build_fold_addr_expr (resdecl_repl); insert_decl_map (&id, DECL_RESULT (old_decl), resdecl_repl); DECL_RESULT (new_decl)