From patchwork Tue Jun 25 14:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1952121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7mr25g61z20X1 for ; Wed, 26 Jun 2024 00:07:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E69FE384188C for ; Tue, 25 Jun 2024 14:07:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2E53A385DDD5 for ; Tue, 25 Jun 2024 14:07:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E53A385DDD5 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E53A385DDD5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719324447; cv=none; b=EeWC2Gtn2Th8rTmTqKceffhThHnJqxfLKv/wfgRXxZBmiNYhYiN2E4SkZMRn+6ZPv+TAg9nK4RQ06KwPL0EO+IcO/4sHVHhrX0V4sWkG7DowS597ltbtNQ0LKqwpuUkTM3XYVL8Mq8zriTRw7qd/HAXtZ+Pkd+ixLAKq7jV4C6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719324447; c=relaxed/simple; bh=iQp4WrSyo01hiqDU2J4U819oa9omqc0D/X87STDF4Ww=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=ls2c9/2+AkrQR8m8YNf02/5tnv7kK3XxTh4bdRyCtYzFYAxyRHLaA84F3p56zHOcdrite6cOQMD4XqkOA9922fAtb1quGnl91Dm4Fx4ps457dQKB1cEnmCwRiEwWEw4UVKo/Ysdg8ACxD1Gh03cy2kW79X2iKMYHf6RN8Za2nTI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9AE43339 for ; Tue, 25 Jun 2024 07:07:48 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D0893F73B for ; Tue, 25 Jun 2024 07:07:23 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] late-combine: Honor targetm.cannot_copy_insn_p Date: Tue, 25 Jun 2024 15:07:22 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-19.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org late-combine was failing to take targetm.cannot_copy_insn_p into account, which led to multiple definitions of PIC symbols on arm*-*-* targets. Currently bootstrapping & regression testing on arm-linux-gnueabihf and aarch64-linus-gnu. It should fix the bootstrap-lto problem reported by Linaro's CI. OK to install if testing passes? Richard gcc/ * late-combine.cc (insn_combination::substitute_nondebug_use): Reject second and subsequent uses if targetm.cannot_copy_insn_p disallows copying. --- gcc/late-combine.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/late-combine.cc b/gcc/late-combine.cc index fc75d1c56d7..b7c0bc07a8b 100644 --- a/gcc/late-combine.cc +++ b/gcc/late-combine.cc @@ -179,6 +179,18 @@ insn_combination::substitute_nondebug_use (use_info *use) if (dump_file && (dump_flags & TDF_DETAILS)) dump_insn_slim (dump_file, use->insn ()->rtl ()); + // Reject second and subsequent uses if the target does not allow + // the defining instruction to be copied. + if (targetm.cannot_copy_insn_p + && m_nondebug_changes.length () >= 2 + && targetm.cannot_copy_insn_p (m_def_insn->rtl ())) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "-- The target does not allow multiple" + " copies of insn %d\n", m_def_insn->uid ()); + return false; + } + // Check that we can change the instruction pattern. Leave recognition // of the result till later. insn_propagation prop (use_rtl, m_dest, m_src);