summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-01-09 10:32:30 +0000
committerOwen Anderson <resistor@mac.com>2008-01-09 10:32:30 +0000
commit77c3fe441b576689b66b2490a4dab61e3beeafc2 (patch)
tree4ab682fe7419eb796f869feddceb3b7ec2c56087
parente0fd9bd35a2a566f2c2a6a6858974602fa46f2c5 (diff)
downloadbcm5719-llvm-77c3fe441b576689b66b2490a4dab61e3beeafc2.tar.gz
bcm5719-llvm-77c3fe441b576689b66b2490a4dab61e3beeafc2.zip
Fix an infinite recursion bug in InsertCopies.
llvm-svn: 45774
-rw-r--r--llvm/lib/CodeGen/StrongPHIElimination.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/StrongPHIElimination.cpp b/llvm/lib/CodeGen/StrongPHIElimination.cpp
index eff02f1fbf9..aa25dfebd80 100644
--- a/llvm/lib/CodeGen/StrongPHIElimination.cpp
+++ b/llvm/lib/CodeGen/StrongPHIElimination.cpp
@@ -101,7 +101,7 @@ namespace {
std::vector<StrongPHIElimination::DomForestNode*>& DF,
std::vector<std::pair<unsigned, unsigned> >& locals);
void ScheduleCopies(MachineBasicBlock* MBB, std::set<unsigned>& pushed);
- void InsertCopies(MachineBasicBlock* MBB);
+ void InsertCopies(MachineBasicBlock* MBB, std::set<MachineBasicBlock*>& v);
};
char StrongPHIElimination::ID = 0;
@@ -610,7 +610,10 @@ void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB,
}
/// InsertCopies - insert copies into MBB and all of its successors
-void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) {
+void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB,
+ std::set<MachineBasicBlock*>& visited) {
+ visited.insert(MBB);
+
std::set<unsigned> pushed;
// Rewrite register uses from Stacks
@@ -629,7 +632,8 @@ void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) {
for (GraphTraits<MachineBasicBlock*>::ChildIteratorType I =
GraphTraits<MachineBasicBlock*>::child_begin(MBB), E =
GraphTraits<MachineBasicBlock*>::child_end(MBB); I != E; ++I)
- InsertCopies(*I);
+ if (!visited.count(*I))
+ InsertCopies(*I, visited);
// As we exit this block, pop the names we pushed while processing it
for (std::set<unsigned>::iterator I = pushed.begin(),
@@ -649,7 +653,8 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
// Insert copies
// FIXME: This process should probably preserve LiveVariables
- InsertCopies(Fn.begin());
+ std::set<MachineBasicBlock*> visited;
+ InsertCopies(Fn.begin(), visited);
// Perform renaming
typedef std::map<unsigned, std::set<unsigned> > RenameSetType;
OpenPOWER on IntegriCloud