[PATCH] D126861: [RISCV] Fix missing stack pointer recover
Kito Cheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 9 08:39:00 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b11f909030a: [RISCV] Fix missing stack pointer recover (authored by kito-cheng).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126861/new/
https://reviews.llvm.org/D126861
Files:
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll
Index: llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll
===================================================================
--- llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll
+++ llvm/test/CodeGen/RISCV/miss-sp-restore-eh.ll
@@ -48,6 +48,7 @@
; CHECK-NEXT: lw s1, 0(a0)
; CHECK-NEXT: call __cxa_end_catch at plt
; CHECK-NEXT: mv a0, s1
+; CHECK-NEXT: addi sp, s0, -32
; CHECK-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
; CHECK-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
; CHECK-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
Index: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -637,7 +637,15 @@
// Restore the stack pointer using the value of the frame pointer. Only
// necessary if the stack pointer was modified, meaning the stack size is
// unknown.
- if (RI->hasStackRealignment(MF) || MFI.hasVarSizedObjects()) {
+ //
+ // In order to make sure the stack point is right through the EH region,
+ // we also need to restore stack pointer from the frame pointer if we
+ // don't preserve stack space within prologue/epilogue for outgoing variables,
+ // normally it's just checking the variable sized object is present or not
+ // is enough, but we also don't preserve that at prologue/epilogue when
+ // have vector objects in stack.
+ if (RI->hasStackRealignment(MF) || MFI.hasVarSizedObjects() ||
+ !hasReservedCallFrame(MF)) {
assert(hasFP(MF) && "frame pointer should not have been eliminated");
adjustReg(MBB, LastFrameDestroy, DL, SPReg, FPReg, -FPOffset,
MachineInstr::FrameDestroy);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126861.435568.patch
Type: text/x-patch
Size: 1726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220609/adfb8aa4/attachment.bin>
More information about the llvm-commits
mailing list