@@ -37,11 +37,12 @@ bool llvm::InlineFunction(InvokeInst *II, CallGraph *CG, const TargetData *TD) {
37
37
// / in the body of the inlined function into invokes and turn unwind
38
38
// / instructions into branches to the invoke unwind dest.
39
39
// /
40
- // / II is the invoke instruction begin inlined. FirstNewBlock is the first
40
+ // / II is the invoke instruction being inlined. FirstNewBlock is the first
41
41
// / block of the inlined code (the last block is the end of the function),
42
42
// / and InlineCodeInfo is information about the code that got inlined.
43
43
static void HandleInlinedInvoke (InvokeInst *II, BasicBlock *FirstNewBlock,
44
- ClonedCodeInfo &InlinedCodeInfo) {
44
+ ClonedCodeInfo &InlinedCodeInfo,
45
+ CallGraph *CG) {
45
46
BasicBlock *InvokeDest = II->getUnwindDest ();
46
47
std::vector<Value*> InvokeDestPHIValues;
47
48
@@ -93,6 +94,10 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
93
94
// Make sure that anything using the call now uses the invoke!
94
95
CI->replaceAllUsesWith (II);
95
96
97
+ // Update the callgraph.
98
+ if (CG)
99
+ (*CG)[Caller]->replaceCallSite (CI, II);
100
+
96
101
// Delete the unconditional branch inserted by splitBasicBlock
97
102
BB->getInstList ().pop_back ();
98
103
Split->getInstList ().pop_front (); // Delete the original call
@@ -433,7 +438,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
433
438
// any inlined 'unwind' instructions into branches to the invoke exception
434
439
// destination, and call instructions into invoke instructions.
435
440
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
436
- HandleInlinedInvoke (II, FirstNewBlock, InlinedFunctionInfo);
441
+ HandleInlinedInvoke (II, FirstNewBlock, InlinedFunctionInfo, CG );
437
442
438
443
// If we cloned in _exactly one_ basic block, and if that block ends in a
439
444
// return instruction, we splice the body of the inlined callee directly into
0 commit comments