From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3B3A7385482B; Sat, 14 Nov 2020 04:05:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B3A7385482B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97682] Miscompiled tail call with -fPIC Date: Sat, 14 Nov 2020 04:05:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Nov 2020 04:05:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97682 --- Comment #4 from CVS Commits --- The master branch has been updated by Jim Wilson : https://gcc.gnu.org/g:207de83922bda8707aa33d6a2185e691116377e7 commit r11-5026-g207de83922bda8707aa33d6a2185e691116377e7 Author: Monk Chiang Date: Fri Nov 13 19:35:11 2020 -0800 PR target/97682 - Fix to reuse t1 register between call address and epilogue. - When expanding the call pattern, choose t1 register be a jump regis= ter. Epilogue also uses a t1 register to adjust Stack point. The call pattern and epilogue will initial t1 twice, if both are generated in the sa= me function. The call pattern will emit 'la t1,symbol' and 'jalr t1'instructions. Epilogue also emits 'li t1,4096' and 'addi sp,sp,t1' instructions. But li and addi instructions will be placed between la and jalr instructions. The la instruction will be removed by some optimizations, because t1 register define twice, the first define instruction look likes duplicate. - To resolve this issue, Prologue and Epilogue use the t0 register be a temporary register, the call pattern use the t1 register be a temporary register. gcc/ 2020-11-13 Monk Chiang PR target/97682 * config/riscv/riscv.h (RISCV_PROLOGUE_TEMP_REGNUM): Change register to t0. (RISCV_CALL_ADDRESS_TEMP_REGNUM): New Marco, define t1 register. (RISCV_CALL_ADDRESS_TEMP): Use it for call instructions. * config/riscv/riscv.c (riscv_legitimize_call_address): Use RISCV_CALL_ADDRESS_TEMP. (riscv_compute_frame_info): Change temporary register to t0 form t1. (riscv_trampoline_init): Adjust comment. gcc/testsuite/ 2020-11-13 Monk Chiang PR target/97682 * g++.target/riscv/pr97682.C: New test. * gcc.target/riscv/interrupt-3.c: Check register for t0. * gcc.target/riscv/interrupt-4.c: Likewise.=