diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 19b65e8e1f..1de7b0753d 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -383,11 +383,17 @@ bool Inliner::runOnSCC(CallGraphSCC &SCC) { if (!shouldInline(CS)) continue; - // Attempt to inline the function... + // Attempt to inline the function. if (!InlineCallIfPossible(CS, InlineInfo, InlinedArrayAllocas)) continue; ++NumInlined; + // If inlining this function devirtualized any call sites, throw them + // onto our worklist to process. They are useful inline candidates. + for (unsigned i = 0, e = InlineInfo.DevirtualizedCalls.size(); + i != e; ++i) + CallSites.push_back(CallSite(InlineInfo.DevirtualizedCalls[i])); + // Update the cached cost info with the inlined call. growCachedCostInfo(Caller, Callee); } diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 5629a38709..a913d157e2 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -170,7 +170,8 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, static void UpdateCallGraphAfterInlining(CallSite CS, Function::iterator FirstNewBlock, DenseMap<const Value*, Value*> &ValueMap, - CallGraph &CG) { + InlineFunctionInfo &IFI) { + CallGraph &CG = *IFI.CG; const Function *Caller = CS.getInstruction()->getParent()->getParent(); const Function *Callee = CS.getCalledFunction(); CallGraphNode *CalleeNode = CG[Callee]; @@ -210,6 +211,10 @@ static void UpdateCallGraphAfterInlining(CallSite CS, if (Function *F = CallSite(NewCall).getCalledFunction()) { // Indirect call site resolved to direct call. CallerNode->addCalledFunction(CallSite::get(NewCall), CG[F]); + + // Remember that this callsite got devirtualized for the client of + // InlineFunction. + IFI.DevirtualizedCalls.push_back(NewCall); continue; } @@ -362,7 +367,7 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI) { // Update the callgraph if requested. if (IFI.CG) - UpdateCallGraphAfterInlining(CS, FirstNewBlock, ValueMap, *IFI.CG); + UpdateCallGraphAfterInlining(CS, FirstNewBlock, ValueMap, IFI); } // If there are any alloca instructions in the block that used to be the entry |