summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/LCSSA.cpp
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
committered <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
commitcf5cd875b51255602afaed29deb636b66b295671 (patch)
tree9794dc36f22f2a2b3f8063829d8a9b3a7794acc8 /lib/Transforms/Utils/LCSSA.cpp
parent5c1b5c146f3df07c75174aff06c3bb0968f6857e (diff)
downloadFreeBSD-src-cf5cd875b51255602afaed29deb636b66b295671.zip
FreeBSD-src-cf5cd875b51255602afaed29deb636b66b295671.tar.gz
Import LLVM r74383.
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp
index 7d4f3a3..d5e7303 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<DomTreeNode*, Value*> 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<InvokeInst>(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));
OpenPOWER on IntegriCloud