aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/PHIElimination.cpp
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
commitb126d0530d48890e1689975483b9f923a0fca1da (patch)
tree7efd65da549a446dde7e9f8e78d12ee888d4a2a0 /lib/CodeGen/PHIElimination.cpp
parenta44321776ecd96fa0344335d3027758be3386e45 (diff)
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PHIElimination.cpp')
-rw-r--r--lib/CodeGen/PHIElimination.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp
index cb0211f38d..c4f2cc7a75 100644
--- a/lib/CodeGen/PHIElimination.cpp
+++ b/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;