[llvm-commits] CVS: llvm/lib/CodeGen/PrologEpilogInserter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Aug 26 15:18:43 PDT 2005
Changes in directory llvm/lib/CodeGen:
PrologEpilogInserter.cpp updated: 1.44 -> 1.45
---
Log message:
Make this code safe for when loadRegFromStackSlot inserts multiple instructions.
---
Diffs of the changes: (+13 -1)
PrologEpilogInserter.cpp | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletion(-)
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
diff -u llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.44 llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.45
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp:1.44 Sat May 14 22:09:58 2005
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp Fri Aug 26 17:18:32 2005
@@ -217,13 +217,25 @@
while (I2 != MBB->begin() && TII.isTerminatorInstr((--I2)->getOpcode()))
I = I2;
+ bool AtStart = I2 == MBB->begin();
+ MachineBasicBlock::iterator BeforeI = I;
+ if (!AtStart)
+ --BeforeI;
+
// 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() &&
"loadRegFromStackSlot didn't insert any code!");
- --I; // Insert in reverse order
+ // Insert in reverse order. loadRegFromStackSlot can insert multiple
+ // instructions.
+ if (AtStart)
+ I = MBB->begin();
+ else {
+ I = BeforeI;
+ ++I;
+ }
}
}
}
More information about the llvm-commits
mailing list