summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2009-11-16 02:00:09 +0000
committerLang Hames <lhames@gmail.com>2009-11-16 02:00:09 +0000
commit968bd90f880a3b418c41393092ecf8c5edd706c1 (patch)
tree8bbaa43d9149e274312bf3876e96f0ae6eebaf68 /llvm/lib/CodeGen
parent2496fe14ec4bf068b80569337e1df1771229c3c6 (diff)
downloadbcm5719-llvm-968bd90f880a3b418c41393092ecf8c5edd706c1.tar.gz
bcm5719-llvm-968bd90f880a3b418c41393092ecf8c5edd706c1.zip
Fix for the original bug in PR5495 - Look at uses as well as defs when determining the PHI-copy insert point.
- Patch by Andrew Canis! llvm-svn: 88880
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/PHIElimination.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/PHIElimination.cpp b/llvm/lib/CodeGen/PHIElimination.cpp
index cb0211f38d8..c4f2cc7a75d 100644
--- a/llvm/lib/CodeGen/PHIElimination.cpp
+++ b/llvm/lib/CodeGen/PHIElimination.cpp
@@ -141,10 +141,10 @@ llvm::PHIElimination::FindCopyInsertPoint(MachineBasicBlock &MBB,
if (!SuccMBB.isLandingPad())
return MBB.getFirstTerminator();
- // Discover any definitions in this basic block.
+ // Discover any defs/uses in this basic block.
SmallPtrSet<MachineInstr*, 8> DefUsesInMBB;
- for (MachineRegisterInfo::def_iterator RI = MRI->def_begin(SrcReg),
- RE = MRI->def_end(); RI != RE; ++RI) {
+ for (MachineRegisterInfo::reg_iterator RI = MRI->reg_begin(SrcReg),
+ RE = MRI->reg_end(); RI != RE; ++RI) {
MachineInstr *DefUseMI = &*RI;
if (DefUseMI->getParent() == &MBB)
DefUsesInMBB.insert(DefUseMI);
@@ -155,11 +155,11 @@ llvm::PHIElimination::FindCopyInsertPoint(MachineBasicBlock &MBB,
// No defs. Insert the copy at the start of the basic block.
InsertPoint = MBB.begin();
} else if (DefUsesInMBB.size() == 1) {
- // Insert the copy immediately after the def.
+ // Insert the copy immediately after the def/use.
InsertPoint = *DefUsesInMBB.begin();
++InsertPoint;
} else {
- // Insert the copy immediately after the last def.
+ // Insert the copy immediately after the last def/use.
InsertPoint = MBB.end();
while (!DefUsesInMBB.count(&*--InsertPoint)) {}
++InsertPoint;
OpenPOWER on IntegriCloud