summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/VirtRegRewriter.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-09-03 18:36:56 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-09-03 18:36:56 +0000
commit662fecd65434ef39122e1908849e29c9e2be8027 (patch)
tree823c856f142512730a4ce562344c4820e185c42c /llvm/lib/CodeGen/VirtRegRewriter.cpp
parent064cb4c80760c133a569c4f45d8d63616972f35b (diff)
downloadbcm5719-llvm-662fecd65434ef39122e1908849e29c9e2be8027.tar.gz
bcm5719-llvm-662fecd65434ef39122e1908849e29c9e2be8027.zip
VirtRegRewriter checks for early clobbers before it reuses an available stack
slot. Teach it to also check for early clobbered aliases, and early clobber operands following the current operand. This fixes the miscompilation in PR8044 where EC registers eax and ecx were being used for inputs. llvm-svn: 112988
Diffstat (limited to 'llvm/lib/CodeGen/VirtRegRewriter.cpp')
-rw-r--r--llvm/lib/CodeGen/VirtRegRewriter.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/VirtRegRewriter.cpp b/llvm/lib/CodeGen/VirtRegRewriter.cpp
index 94a64ceec93..d988e106c52 100644
--- a/llvm/lib/CodeGen/VirtRegRewriter.cpp
+++ b/llvm/lib/CodeGen/VirtRegRewriter.cpp
@@ -2027,14 +2027,16 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
CanReuse = !ReusedOperands.isClobbered(PhysReg) &&
Spills.canClobberPhysReg(PhysReg);
}
- // If this is an asm, and PhysReg is used elsewhere as an earlyclobber
- // operand, we can't also use it as an input. (Outputs always come
- // before inputs, so we can stop looking at i.)
+ // If this is an asm, and a PhysReg alias is used elsewhere as an
+ // earlyclobber operand, we can't also use it as an input.
if (MI.isInlineAsm()) {
- for (unsigned k=0; k<i; ++k) {
+ for (unsigned k = 0, e = MI.getNumOperands(); k != e; ++k) {
MachineOperand &MOk = MI.getOperand(k);
- if (MOk.isReg() && MOk.getReg()==PhysReg && MOk.isEarlyClobber()) {
+ if (MOk.isReg() && MOk.isEarlyClobber() &&
+ TRI->regsOverlap(MOk.getReg(), PhysReg)) {
CanReuse = false;
+ DEBUG(dbgs() << "Not reusing physreg " << TRI->getName(PhysReg)
+ << " for vreg" << VirtReg << ": " << MOk << '\n');
break;
}
}
OpenPOWER on IntegriCloud