Skip to content

Commit

Permalink
[RISCV] fix SP recovery in varargs functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dlav-sc committed Nov 5, 2024
1 parent 4a04dd4 commit 39f58fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,9 +809,7 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
uint64_t StackSize = FirstSPAdjustAmount ? FirstSPAdjustAmount
: getStackSizeWithRVVPadding(MF) -
RVFI->getReservedSpillsSize();
uint64_t FPOffset = FirstSPAdjustAmount ? FirstSPAdjustAmount
: getStackSizeWithRVVPadding(MF) -
RVFI->getVarArgsSaveSize();
uint64_t FPOffset = RealStackSize - RVFI->getVarArgsSaveSize();
uint64_t RVVStackSize = RVFI->getRVVStackSize();

bool RestoreFP = RI->hasStackRealignment(MF) || MFI.hasVarSizedObjects() ||
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/RISCV/varargs-with-fp-and-second-adj.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define dso_local void @_Z3fooPKcz(ptr noundef %0, ...) "frame-pointer"="all" {
; RV64V-NEXT: sd a0, -32(s0)
; RV64V-NEXT: addi a0, s0, 8
; RV64V-NEXT: sd a0, -40(s0)
; RV64V-NEXT: addi sp, s0, -496
; RV64V-NEXT: addi sp, s0, -432
; RV64V-NEXT: ld ra, 424(sp) # 8-byte Folded Reload
; RV64V-NEXT: ld s0, 416(sp) # 8-byte Folded Reload
; RV64V-NEXT: addi sp, sp, 496
Expand Down

0 comments on commit 39f58fb

Please sign in to comment.