mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 17:32:49 +00:00
Make this code safe for when loadRegFromStackSlot inserts multiple instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23108 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
28b9cc2d13
commit
ed461e0faf
@ -217,13 +217,25 @@ void PEI::saveCallerSavedRegisters(MachineFunction &Fn) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user