From 6b9c959c61e77b1bc78a93ee4a6cac8eaa656a21 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 26 Jun 2009 00:31:13 +0000 Subject: Fix LCSSA to avoid emitting a PHI node for the unwind destination of an invoke instruction, since the value isn't really live across that edge. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74242 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/LCSSA.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/Transforms/Utils/LCSSA.cpp') diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp index 7d4f3a343e..d5e7303a50 100644 --- a/lib/Transforms/Utils/LCSSA.cpp +++ b/lib/Transforms/Utils/LCSSA.cpp @@ -149,7 +149,16 @@ void LCSSA::ProcessInstruction(Instruction *Instr, // Keep track of the blocks that have the value available already. DenseMap Phis; - DomTreeNode *InstrNode = DT->getNode(Instr->getParent()); + BasicBlock *DomBB = Instr->getParent(); + + // Invoke instructions are special in that their result value is not available + // along their unwind edge. The code below tests to see whether DomBB dominates + // the value, so adjust DomBB to the normal destination block, which is + // effectively where the value is first usable. + if (InvokeInst *Inv = dyn_cast(Instr)) + DomBB = Inv->getNormalDest(); + + DomTreeNode *DomNode = DT->getNode(DomBB); // Insert the LCSSA phi's into the exit blocks (dominated by the value), and // add them to the Phi's map. @@ -158,7 +167,7 @@ void LCSSA::ProcessInstruction(Instruction *Instr, BasicBlock *BB = *BBI; DomTreeNode *ExitBBNode = DT->getNode(BB); Value *&Phi = Phis[ExitBBNode]; - if (!Phi && DT->dominates(InstrNode, ExitBBNode)) { + if (!Phi && DT->dominates(DomNode, ExitBBNode)) { PHINode *PN = PHINode::Create(Instr->getType(), Instr->getName()+".lcssa", BB->begin()); PN->reserveOperandSpace(PredCache.GetNumPreds(BB)); -- cgit v1.2.3-70-g09d2