[llvm-commits] [llvm] r68120 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/Other/2009-03-31-CallGraph.ll
Devang Patel
dpatel at apple.com
Tue Mar 31 10:36:12 PDT 2009
Author: dpatel
Date: Tue Mar 31 12:36:12 2009
New Revision: 68120
URL: http://llvm.org/viewvc/llvm-project?rev=68120&view=rev
Log:
Update call graph after inlining invoke.
Patch by Jay Foad.
Added:
llvm/trunk/test/Other/2009-03-31-CallGraph.ll
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=68120&r1=68119&r2=68120&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Mar 31 12:36:12 2009
@@ -41,7 +41,8 @@
/// 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 @@
// 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 @@
// 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
Added: llvm/trunk/test/Other/2009-03-31-CallGraph.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/2009-03-31-CallGraph.ll?rev=68120&view=auto
==============================================================================
--- llvm/trunk/test/Other/2009-03-31-CallGraph.ll (added)
+++ llvm/trunk/test/Other/2009-03-31-CallGraph.ll Tue Mar 31 12:36:12 2009
@@ -0,0 +1,31 @@
+; RUN: llvm-as < %s | opt -inline -prune-eh -disable-output
+define void @f2() {
+ invoke void @f6()
+ to label %ok1 unwind label %lpad1
+
+ok1:
+ ret void
+
+lpad1:
+ invoke void @f4()
+ to label %ok2 unwind label %lpad2
+
+ok2:
+ call void @f8()
+ unreachable
+
+lpad2:
+ unreachable
+}
+
+declare void @f3()
+
+define void @f4() {
+ call void @f3()
+ ret void
+}
+
+declare void @f6() nounwind
+
+declare void @f8()
+
More information about the llvm-commits
mailing list