Skip to content

Commit 72de7ca

Browse files
INetBowserandreisfr
authored andcommitted
[Xtensa] Remove unnecessary MOVSP in epilogue.
Signed-off-by: Andrei Safronov <[email protected]>
1 parent 66e092d commit 72de7ca

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
@@ -245,8 +245,13 @@ void XtensaFrameLowering::emitEpilogue(MachineFunction &MF,
245245
for (unsigned i = 0; i < MFI.getCalleeSavedInfo().size(); ++i)
246246
--I;
247247
if (STI.isWinABI()) {
248-
// Insert instruction "movsp $sp, $fp" at this location.
249-
BuildMI(MBB, I, dl, TII.get(Xtensa::MOVSP), SP).addReg(FP);
248+
// In most architectures, we need to explicitly restore the stack pointer
249+
// before returning.
250+
//
251+
// For Xtensa Windowed Register option, it is not needed to explicitly
252+
// restore the stack pointer. Reason being is that on function return,
253+
// the window of the caller (including the old stack pointer) gets
254+
// restored anyways.
250255
} else {
251256
BuildMI(MBB, I, dl, TII.get(Xtensa::OR), SP).addReg(FP).addReg(FP);
252257
}

0 commit comments

Comments
 (0)