diff options
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r-- | lib/Transforms/Utils/LCSSA.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index ed02c97743..ac540c9aaa 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -155,13 +155,16 @@ void LCSSA::processInstruction(Instruction* Instr, std::vector<PHINode*> workList; for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(), - BBE = exitBlocks.end(); BBI != BBE; ++BBI) - if (DT->getNode(Instr->getParent())->dominates(DT->getNode(*BBI))) { - PHINode *phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa", + BBE = exitBlocks.end(); BBI != BBE; ++BBI) { + Instruction*& phi = Phis[*BBI]; + if (phi == 0 && + DT->getNode(Instr->getParent())->dominates(DT->getNode(*BBI))) { + phi = new PHINode(Instr->getType(), Instr->getName()+".lcssa", (*BBI)->begin()); - workList.push_back(phi); + workList.push_back(cast<PHINode>(phi)); Phis[*BBI] = phi; } + } // Phi nodes that need to have their incoming values filled. std::vector<PHINode*> needIncomingValues; |