diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-22 23:37:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-22 23:37:35 +0000 |
commit | 2eee5d3467d1e2944374ab3f5c68456ac7855113 (patch) | |
tree | eccda60b828d649ce94eb8b23e52562209d9c400 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | ff1915208d94a3a2876dc5d794a27bba44a1c8ae (diff) | |
download | llvm-2eee5d3467d1e2944374ab3f5c68456ac7855113.zip llvm-2eee5d3467d1e2944374ab3f5c68456ac7855113.tar.gz llvm-2eee5d3467d1e2944374ab3f5c68456ac7855113.tar.bz2 |
The inliner was choosing to not consider call sites
that appear in the SCC as a result of inlining as candidates
for inlining. Change this so that it *does* consider call
sites that change from being indirect to being direct as a
result of inlining. This allows it to completely
"devirtualize" the testcase.
llvm-svn: 102146
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 5629a38..a913d15 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/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 |