[llvm] [RISCV][CFI] add function epilogue cfi information (PR #110810)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 15 07:48:54 PDT 2024
================
@@ -51,10 +56,15 @@ define void @test_scoped_alloca(i64 %n) {
; RV64-NEXT: call use_addr
; RV64-NEXT: mv sp, s1
; RV64-NEXT: addi sp, s0, -32
+; RV64-NEXT: .cfi_def_cfa sp, 32
----------------
lenary wrote:
This function, for example, looks correct:
- The prolog sets a CFA offset (i recall, from `sp`?)
- Then it says where a bunch of registers have been saved, relative to that CFA
- Then the `.cfi_def_cfa s0, 0` directive, i believe, says "now, to calculate the CFA, use `s0+0`"
- Most of the function happens
- You then get to the epilog and say "now calculate the CFA as `sp+0`" using this line
- You then restore the value of `ra`, `s0`, and `s1`
This means if a debugger stops between the `ld s0, 16(sp)` and the `ret`, then asking where some variables are kept should not use a calculation based on the restored `s0`, it should now be based on `sp`.
https://github.com/llvm/llvm-project/pull/110810
More information about the llvm-commits
mailing list