[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Oct 26 23:34:00 PST 2003
Changes in directory llvm/lib/Transforms/Utils:
InlineFunction.cpp updated: 1.14 -> 1.15
---
Log message:
Get the list of PHI node values before the basic block is split. Also, add
PHI node entries for unwind instructions just like for call instructions which
became invokes! This fixes PR57, tested by
Inline/2003-10-26-InlineInvokeExceptionDestPhi.ll
---
Diffs of the changes: (+16 -9)
Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.14 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.15
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.14 Mon Oct 20 14:43:20 2003
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp Sun Oct 26 23:33:09 2003
@@ -60,6 +60,15 @@
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
InvokeDest = II->getExceptionalDest();
+ // If there are PHI nodes in the exceptional destination block, we need to
+ // keep track of which values came into them from this invoke, then remove
+ // the entry for this block.
+ for (BasicBlock::iterator I = InvokeDest->begin();
+ PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+ // Save the value to use for this edge...
+ InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(OrigBB));
+ }
+
// Add an unconditional branch to make this look like the CallInst case...
BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall);
@@ -69,15 +78,6 @@
AfterCallBB = OrigBB->splitBasicBlock(NewBr,
CalledFunc->getName()+".entry");
- // If there are PHI nodes in the exceptional destination block, we need to
- // keep track of which values came into them from this invoke, then remove
- // the entry for this block.
- for (BasicBlock::iterator I = InvokeDest->begin();
- PHINode *PN = dyn_cast<PHINode>(I); ++I) {
- // Save the value to use for this edge...
- InvokeDestPHIValues.push_back(PN->getIncomingValueForBlock(AfterCallBB));
- }
-
// Remove (unlink) the InvokeInst from the function...
OrigBB->getInstList().remove(TheCall);
@@ -240,6 +240,13 @@
// Delete the unwind instruction!
UI->getParent()->getInstList().pop_back();
+
+ // Update any PHI nodes in the exceptional block to indicate that
+ // there is now a new entry in them.
+ unsigned i = 0;
+ for (BasicBlock::iterator I = InvokeDest->begin();
+ PHINode *PN = dyn_cast<PHINode>(I); ++I, ++i)
+ PN->addIncoming(InvokeDestPHIValues[i], BB);
}
}
More information about the llvm-commits
mailing list