If a single exit block has multiple predecessors within the loop, it will
appear in the exit blocks list more than once. LCSSA needs to take that into
account so that it doesn't double process that exit block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28750
91177308-0d34-0410-b5e6-
96231b3b80d8
std::vector<PHINode*> workList;
for (std::vector<BasicBlock*>::const_iterator BBI = exitBlocks.begin(),
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",
- workList.push_back(phi);
+ workList.push_back(cast<PHINode>(phi));
// Phi nodes that need to have their incoming values filled.
std::vector<PHINode*> needIncomingValues;
// Phi nodes that need to have their incoming values filled.
std::vector<PHINode*> needIncomingValues;