From 38804d99713f5ed619a964e427c001e4b1c12e02 Mon Sep 17 00:00:00 2001 From: INetBowser Date: Sat, 23 Jan 2021 11:41:12 +0100 Subject: [PATCH] [Xtensa] Remove unnecessary MOVSP in epilogue. --- llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp b/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp index 0073d7c593013..5ae330a53a295 100644 --- a/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp +++ b/llvm/lib/Target/Xtensa/XtensaFrameLowering.cpp @@ -245,8 +245,13 @@ void XtensaFrameLowering::emitEpilogue(MachineFunction &MF, for (unsigned i = 0; i < MFI.getCalleeSavedInfo().size(); ++i) --I; if (STI.isWinABI()) { - // Insert instruction "movsp $sp, $fp" at this location. - BuildMI(MBB, I, dl, TII.get(Xtensa::MOVSP), SP).addReg(FP); + // In most architectures, we need to explicitly restore the stack pointer + // before returning. + // + // For Xtensa Windowed Register option, it is not needed to explicitly + // restore the stack pointer. Reason being is that on function return, + // the window of the caller (including the old stack pointer) gets + // restored anyways. } else { BuildMI(MBB, I, dl, TII.get(Xtensa::OR), SP).addReg(FP).addReg(FP); }