From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 4AEEE3836029; Tue, 10 May 2022 08:25:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AEEE3836029 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10695] aarch64: Fix up RTL sharing bug in aarch64_load_symref_appropriately [PR104910] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 1ebc65fde4dd30678da10a17c6cc29bc4e1e041e X-Git-Newrev: c9b590a80fbe16a118acdbab15e6f82853db6806 Message-Id: <20220510082515.4AEEE3836029@sourceware.org> Date: Tue, 10 May 2022 08:25:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 08:25:15 -0000 https://gcc.gnu.org/g:c9b590a80fbe16a118acdbab15e6f82853db6806 commit r10-10695-gc9b590a80fbe16a118acdbab15e6f82853db6806 Author: Jakub Jelinek Date: Wed Mar 16 11:04:16 2022 +0100 aarch64: Fix up RTL sharing bug in aarch64_load_symref_appropriately [PR104910] 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. 2022-03-16 Jakub Jelinek PR target/104910 * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Copy imm rtx. * gcc.dg/pr104910.c: New test. (cherry picked from commit 952155629ca1a4dfe7c7b26e53d118a9b853ed4a) Diff: --- gcc/config/aarch64/aarch64.c | 2 +- gcc/testsuite/gcc.dg/pr104910.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 1e08f4caa11..d934dd67fc5 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -3123,7 +3123,7 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, 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; } diff --git a/gcc/testsuite/gcc.dg/pr104910.c b/gcc/testsuite/gcc.dg/pr104910.c new file mode 100644 index 00000000000..10fed8147de --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr104910.c @@ -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 (); +}