From patchwork Tue Mar 15 18:32:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 51985 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C7533858C60 for ; Tue, 15 Mar 2022 18:32:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C7533858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1647369178; bh=WLPQFXczBgVfQziGl+3f5TcKw1qtcjSjB5y+VmsOFd8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rVVdCElOqKFHpCfqxMob+GK4ko+Daa9Gr7dZ3BNiHokcBmSg9UQICgHJZqoNqAy2r 8SxAcVLsbt5vdPT8rrloYgFG67lz1AyspfPIsbxvmhV3s74qbGihdPR5d1gpXX1iKo dm/QGcVf0bG1DErFAJQyMmW8phAuqqVts4tIMg4o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 641083858D20 for ; Tue, 15 Mar 2022 18:32:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 641083858D20 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-iazJOlrjPjK7MrAE4bRTwg-1; Tue, 15 Mar 2022 14:32:21 -0400 X-MC-Unique: iazJOlrjPjK7MrAE4bRTwg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 578F6101CC60; Tue, 15 Mar 2022 18:32:21 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1834440885A1; Tue, 15 Mar 2022 18:32:20 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 22FIWIDE2209628 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 15 Mar 2022 19:32:18 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22FIWH8f2209627; Tue, 15 Mar 2022 19:32:17 +0100 Date: Tue, 15 Mar 2022 19:32:17 +0100 To: Richard Earnshaw , Richard Sandiford , Marcus Shawcroft , Kyrylo Tkachov Subject: [PATCH] aarch64: Fix up RTL sharing bug in aarch64_load_symref_appropriately [PR104910] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! We unshare all RTL created during expansion, but when aarch64_load_symref_appropriately is called after expansion like in the following testcases, we use imm in both HIGH and LO_SUM operands. If imm is some RTL that shouldn't be shared like a non-sharable CONST, we get at least with --enable-checking=rtl a checking ICE, otherwise might just get silently wrong code. The following patch fixes that by copying it if it can't be shared. Bootstrapped/regtested on aarch64-linux, ok for trunk? 2022-03-15 Jakub Jelinek PR target/104910 * config/aarch64/aarch64.cc (aarch64_load_symref_appropriately): Copy imm rtx. * gcc.dg/pr104910.c: New test. Jakub --- gcc/config/aarch64/aarch64.cc.jj 2022-02-22 10:38:02.404689359 +0100 +++ gcc/config/aarch64/aarch64.cc 2022-03-14 12:42:00.218975192 +0100 @@ -3971,7 +3971,7 @@ aarch64_load_symref_appropriately (rtx d if (can_create_pseudo_p ()) tmp_reg = gen_reg_rtx (mode); - emit_move_insn (tmp_reg, gen_rtx_HIGH (mode, imm)); + emit_move_insn (tmp_reg, gen_rtx_HIGH (mode, copy_rtx (imm))); emit_insn (gen_add_losym (dest, tmp_reg, imm)); return; } --- gcc/testsuite/gcc.dg/pr104910.c.jj 2022-03-14 12:46:20.983327114 +0100 +++ gcc/testsuite/gcc.dg/pr104910.c 2022-03-14 12:46:06.064535794 +0100 @@ -0,0 +1,14 @@ +/* PR target/104910 */ +/* { dg-do compile } */ +/* { dg-options "-Os -fno-forward-propagate" } */ +/* { dg-additional-options "-fstack-protector-all" { target fstack_protector } } */ + +void +bar (void); + +void +foo (int x) +{ + if (x) + bar (); +}