Skip to content

Commit 7569ae1

Browse files
committed
[Xtensa] Remove unnecessary MOVSP in epilogue.
1 parent 958aa6f commit 7569ae1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,13 @@ void XtensaFrameLowering::emitEpilogue(MachineFunction &MF,
247247
for (unsigned i = 0; i < MFI.getCalleeSavedInfo().size(); ++i)
248248
--I;
249249
if (STI.isWinABI()) {
250-
// Insert instruction "movsp $sp, $fp" at this location.
251-
BuildMI(MBB, I, dl, TII.get(Xtensa::MOVSP), SP).addReg(FP);
250+
// In most architectures, we need to explicitly restore the stack pointer
251+
// before returning.
252+
//
253+
// For Xtensa Windowed Register option, it is not needed to explicitly
254+
// restore the stack pointer. Reason being is that on function return,
255+
// the window of the caller (including the old stack pointer) gets
256+
// restored anyways.
252257
} else {
253258
BuildMI(MBB, I, dl, TII.get(Xtensa::OR), SP).addReg(FP).addReg(FP);
254259
}

0 commit comments

Comments
 (0)