From: Owen Anderson Date: Wed, 9 Jan 2008 10:32:30 +0000 (+0000) Subject: Fix an infinite recursion bug in InsertCopies. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=719fef648d8ed584fdd2b3e7c967cf0fe8c7925b;p=oota-llvm.git Fix an infinite recursion bug in InsertCopies. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index eff02f1fbf9..aa25dfebd80 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -101,7 +101,7 @@ namespace { std::vector& DF, std::vector >& locals); void ScheduleCopies(MachineBasicBlock* MBB, std::set& pushed); - void InsertCopies(MachineBasicBlock* MBB); + void InsertCopies(MachineBasicBlock* MBB, std::set& 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& visited) { + visited.insert(MBB); + std::set pushed; // Rewrite register uses from Stacks @@ -629,7 +632,8 @@ void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) { for (GraphTraits::ChildIteratorType I = GraphTraits::child_begin(MBB), E = GraphTraits::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::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 visited; + InsertCopies(Fn.begin(), visited); // Perform renaming typedef std::map > RenameSetType;