diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-27 05:33:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-27 05:33:09 +0000 |
commit | 198f4507e2ff934a8ac3aa0a82526fa6a153b70b (patch) | |
tree | 650cc168131ddac678f8eed61254d8d36658b392 /lib/Transforms/Utils/InlineFunction.cpp | |
parent | 5bf9ce9a3ac629be4e455f57c7afcca4da9f551b (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 735142b78c..1481324330 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -60,6 +60,15 @@ bool InlineFunction(CallSite CS) { 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 @@ bool InlineFunction(CallSite CS) { 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 @@ bool InlineFunction(CallSite CS) { // 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); } } |