[llvm] [RISCV][CFI] add function epilogue cfi information (PR #110234)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 00:29:06 PDT 2024


================
@@ -284,7 +316,10 @@ define i32 @caller_float_on_stack() {
 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a3, 0
 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    li a5, 0
 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    call callee_float_on_stack
+; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore ra
+; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore s0
 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 12
+; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 0
 ; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
----------------
kito-cheng wrote:

```suggestion
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 12
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 8
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore ra
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore s0
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 0
```

Or something like below is fine, (this is not precise enough but it's separate issue which is not introduced by your fix)
```
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    addi sp, sp, 12
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    tail __riscv_restore_1
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore ra
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_restore s0
; ILP32E-WITHFP-SAVE-RESTORE-NEXT:    .cfi_def_cfa_offset 0
```


https://github.com/llvm/llvm-project/pull/110234


More information about the llvm-commits mailing list