Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions llvm/lib/Target/ARM/Thumb1FrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,16 +1049,28 @@ static void popRegsFromStack(MachineBasicBlock &MBB,
continue;

if (Reg == ARM::LR) {
if (!MBB.succ_empty() ||
MI->getOpcode() == ARM::TCRETURNdi ||
MI->getOpcode() == ARM::TCRETURNri)
// LR may only be popped into PC, as part of return sequence.
// If this isn't the return sequence, we'll need emitPopSpecialFixUp
// to restore LR the hard way.
// FIXME: if we don't pass any stack arguments it would be actually
if (!MBB.succ_empty() || MI->getOpcode() == ARM::TCRETURNdi ||
MI->getOpcode() == ARM::TCRETURNri) {

// If we don't pass any stack arguments it would be actually
// advantageous *and* correct to do the conversion to an ordinary call
// instruction here.
continue;

// Get the MachineFrameInfo.
const MachineFrameInfo &MFI = MF.getFrameInfo();

// Check if there are any stack arguments.
bool hasStackArgs = MFI.hasStackObjects();

// If we have stack args, then LR may only be popped into PC,
// as part of the return sequence.
//
// If this isn't the return sequence, and we have the stack to deal
// with, we'll need emitPopSpecialFixUp to restore LR the hard way.
if (hasStackArgs)
continue;
}

// Special epilogue for vararg functions. See emitEpilogue
if (IsVarArg)
continue;
Expand Down