From 3d2aa47bd3a9e2ea5fdcf1690fa280a5199f4d81 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Mon, 12 Jun 2006 07:10:16 +0000 Subject: [PATCH] Fix for 2006-06-26-MultipleExitsSingleBlock. 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 --- lib/Transforms/Utils/LCSSA.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index ed02c977430..ac540c9aaac 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -155,13 +155,16 @@ void LCSSA::processInstruction(Instruction* Instr, std::vector workList; for (std::vector::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(phi)); Phis[*BBI] = phi; } + } // Phi nodes that need to have their incoming values filled. std::vector needIncomingValues;