]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR target/97682 - Fix to reuse t1 register between call address and epilogue.
authorMonk Chiang <monk.chiang@sifive.com>
Sat, 14 Nov 2020 03:35:11 +0000 (19:35 -0800)
committerKito Cheng <kito.cheng@sifive.com>
Tue, 17 Nov 2020 03:51:44 +0000 (11:51 +0800)
commit4ba2f918583089172ac899c8eecaddef0d47cd85
tree5f4f9887c623bbf700ceb37537d7df5b5fc09702
parent89c56456573412b9fd31968d68085f6a993be13f
PR target/97682 - Fix to reuse t1 register between call address and epilogue.

  - When expanding the call pattern, choose t1 register be a jump register.
    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 same
    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  <monk.chiang@sifive.com>

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  <monk.chiang@sifive.com>

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.

(cherry picked from commit 207de83922bda8707aa33d6a2185e691116377e7)
gcc/config/riscv/riscv.c
gcc/config/riscv/riscv.h
gcc/testsuite/g++.target/riscv/pr97682.C [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/interrupt-3.c
gcc/testsuite/gcc.target/riscv/interrupt-4.c