summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2008-03-03 22:11:16 +0000
committerBill Wendling <isanbard@gmail.com>2008-03-03 22:11:16 +0000
commit4836d58f89e2809940b7de4e78ab018510595f11 (patch)
treeed73a4a67f48efe749f309bdb2fc23117d88e398 /llvm/lib
parentbe750abfd4f1234792392370b36d12f7f3fb54b9 (diff)
downloadbcm5719-llvm-4836d58f89e2809940b7de4e78ab018510595f11.tar.gz
bcm5719-llvm-4836d58f89e2809940b7de4e78ab018510595f11.zip
Multiple instructions can be inserted when eliminating frame indexes. We need
the register scavenger to process all of those new instructions instead of just the last one inserted. llvm-svn: 47860
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/PrologEpilogInserter.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index 31064558509..d14d71026ef 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -530,27 +530,44 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) {
// Visit the instructions created by eliminateCallFramePseudoInstr().
I = next(PrevI);
MI = NULL;
- } else if (I->getOpcode() == TargetInstrInfo::DECLARE)
+ } else if (I->getOpcode() == TargetInstrInfo::DECLARE) {
// Ignore it.
- I++;
- else {
- I++;
+ ++I;
+ } else {
+ bool DoIncr = true;
+
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
if (MI->getOperand(i).isFrameIndex()) {
+ // Some instructions (e.g. inline asm instructions) can have
+ // multiple frame indices and/or cause eliminateFrameIndex to insert
+ // more than one instruction. We need the register scavenger to go
+ // through all of these instructions so that it can update its
+ // register information. We keep the iterator at the point before
+ // insertion so that we can revisit them in full.
+ bool AtBeginning = (I == BB->begin());
+ if (!AtBeginning) --I;
+
// If this instruction has a FrameIndex operand, we need to use that
// target machine register info object to eliminate it.
TRI.eliminateFrameIndex(MI, SPAdj, RS);
- // Revisit the instruction in full. Some instructions (e.g. inline
- // asm instructions) can have multiple frame indices.
- --I;
+ // Reset the iterator if we were at the beginning of the BB.
+ if (AtBeginning) {
+ I = BB->begin();
+ DoIncr = false;
+ }
+
MI = 0;
break;
}
+
+ if (DoIncr) ++I;
}
+
// Update register states.
if (RS && MI) RS->forward(MI);
}
+
assert(SPAdj == 0 && "Unbalanced call frame setup / destroy pairs?");
}
}
OpenPOWER on IntegriCloud