[PATCH] D111519: [WIP] [RISCV] Emit cfi directives for function epilogue
Shivam Gupta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 14 09:40:42 PST 2021
xgupta added a comment.
In D111519#3115534 <https://reviews.llvm.org/D111519#3115534>, @jrtc27 wrote:
> In D111519#3115513 <https://reviews.llvm.org/D111519#3115513>, @xgupta wrote:
>
>> Hello @luismarques,
>>
>> can you please tell me how you have generated this assembly mentioned in the commit summary(.c file)?
>>
>> define void @branch_and_tail_call(i1 %a) {
>> ; RV32-LABEL: branch_and_tail_call:
>> ; RV32: # %bb.0:
>> ; RV32-NEXT: addi sp, sp, -16
>> ; RV32-NEXT: .cfi_def_cfa_offset 16
>> ; RV32-NEXT: sw ra, 12(sp)
>> ; RV32-NEXT: .cfi_offset ra, -4
>> ; RV32-NEXT: andi a0, a0, 1
>> ; RV32-NEXT: beqz a0, .LBB2_2
>> ; RV32-NEXT: # %bb.1: # %blue_pill
>> ; RV32-NEXT: lw ra, 12(sp)
>> ; RV32-NEXT: .cfi_restore ra
>> ; RV32-NEXT: addi sp, sp, 16
>> ; RV32-NEXT: .cfi_def_cfa_offset 0
>> ; RV32-NEXT: tail foo
>> ; RV32-NEXT: .LBB2_2: # %red_pill
>> ; RV32-NEXT: call bar
>> ; RV32-NEXT: lw ra, 12(sp)
>> ; RV32-NEXT: .cfi_restore ra
>> ; RV32-NEXT: addi sp, sp, 16
>> ; RV32-NEXT: .cfi_def_cfa_offset 0
>> ; RV32-NEXT: ret
>> }
>
> This is clearly the branch_and_tail_call test case in frame-info.ll that had the `; FIXME: fix use of .cfi_restore with wrong CFAs`.
I am still looking for .c file so that I can test/diff it (clang riscv assembly) with gcc riscv generated assembly. Side question if someone knows why clang riscv emits .cfi_restore in epilogue (for frame-info.ll after applying this patch) while clang x86 does not. What is the use of .cf_restore in riscv that is not needed in x86? I have read .cfi_restore directive in https://sourceware.org/binutils/docs/as/CFI-directives.html but definition didn't give the answer.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111519/new/
https://reviews.llvm.org/D111519
More information about the llvm-commits
mailing list