From 54bf1cc31349a89af4f69a429427429a025fc196 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 15 May 2005 03:09:58 +0000 Subject: [PATCH] When inserting callee-save register reloads, make sure to skip over any terminator instructions before the 'ret' in case the target has a multi-instruction return sequence. llvm-svn: 22041 --- lib/CodeGen/PrologEpilogInserter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 37e40c90a95..c5bc2337fd7 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -211,6 +211,14 @@ void PEI::saveCallerSavedRegisters(MachineFunction &Fn) { MBB = FI; I = MBB->end(); --I; + // Skip over all terminator instructions, which are part of the return + // sequence. + MachineBasicBlock::iterator I2 = I; + while (I2 != MBB->begin() && TII.isTerminatorInstr((--I2)->getOpcode())) + I = I2; + + // Restore all registers immediately before the return and any terminators + // that preceed it. for (unsigned i = 0, e = RegsToSave.size(); i != e; ++i) { RegInfo->loadRegFromStackSlot(*MBB, I, RegsToSave[i], StackSlots[i]); assert(I != MBB->begin() &&