diff options
| author | Devang Patel <dpatel@apple.com> | 2009-03-31 17:36:12 +0000 | 
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-03-31 17:36:12 +0000 | 
| commit | 4ce6e69022f937e64927c372b9ffa421d80577b2 (patch) | |
| tree | d6297f96da23b65305f40a4fa8677760e1b16b0f /llvm/lib/Transforms/Utils | |
| parent | d640be24fd92c0814f7a83e597adf0b8b00e4566 (diff) | |
| download | bcm5719-llvm-4ce6e69022f937e64927c372b9ffa421d80577b2.tar.gz bcm5719-llvm-4ce6e69022f937e64927c372b9ffa421d80577b2.zip | |
Update call graph after inlining invoke.
Patch by Jay Foad.
llvm-svn: 68120
Diffstat (limited to 'llvm/lib/Transforms/Utils')
| -rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 21 | 
1 files changed, 19 insertions, 2 deletions
| diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index a96c7ceaa8e..1b677fbc2bc 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -41,7 +41,8 @@ bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD) {  /// block of the inlined code (the last block is the end of the function),  /// and InlineCodeInfo is information about the code that got inlined.  static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, -                                ClonedCodeInfo &InlinedCodeInfo) { +                                ClonedCodeInfo &InlinedCodeInfo, +                                CallGraph *CG) {    BasicBlock *InvokeDest = II->getUnwindDest();    std::vector<Value*> InvokeDestPHIValues; @@ -93,6 +94,22 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,            // Make sure that anything using the call now uses the invoke!            CI->replaceAllUsesWith(II); +          // Update the callgraph. +          if (CG) { +            // We should be able to do this: +            //   (*CG)[Caller]->replaceCallSite(CI, II); +            // but that fails if the old call site isn't in the call graph, +            // which, because of LLVM bug 3601, it sometimes isn't. +            CallGraphNode *CGN = (*CG)[Caller]; +            for (CallGraphNode::iterator NI = CGN->begin(), NE = CGN->end(); +                 NI != NE; ++NI) { +              if (NI->first == CI) { +                NI->first = II; +                break; +              } +            } +          } +            // Delete the unconditional branch inserted by splitBasicBlock            BB->getInstList().pop_back();            Split->getInstList().pop_front();  // Delete the original call @@ -433,7 +450,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {    // any inlined 'unwind' instructions into branches to the invoke exception    // destination, and call instructions into invoke instructions.    if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) -    HandleInlinedInvoke(II, FirstNewBlock, InlinedFunctionInfo); +    HandleInlinedInvoke(II, FirstNewBlock, InlinedFunctionInfo, CG);    // If we cloned in _exactly one_ basic block, and if that block ends in a    // return instruction, we splice the body of the inlined callee directly into | 

