summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/Inliner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-12 05:37:29 +0000
committerChris Lattner <sabre@nondot.org>2004-04-12 05:37:29 +0000
commitce1a3a292d7696c973efe27809384d33a530dd65 (patch)
treee13247a9f1117df365b56430d48eb86a14863d2d /lib/Transforms/IPO/Inliner.cpp
parentb81c021f14107b12d1275c84fbce170db06437a5 (diff)
downloadllvm-ce1a3a292d7696c973efe27809384d33a530dd65.tar.gz
llvm-ce1a3a292d7696c973efe27809384d33a530dd65.tar.bz2
llvm-ce1a3a292d7696c973efe27809384d33a530dd65.tar.xz
Actually update the call graph as the inliner changes it. This allows us to
execute other CallGraphSCCPasses after the inliner without crashing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12861 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/Inliner.cpp')
-rw-r--r--lib/Transforms/IPO/Inliner.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index 808d3930b6..8633a7e950 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -93,7 +93,21 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
// Attempt to inline the function...
if (InlineFunction(CS)) {
++NumInlined;
+
+ // Update the call graph by deleting the edge from Callee to Caller
+ CallGraphNode *CalleeNode = CG[Callee];
+ CallGraphNode *CallerNode = CG[Caller];
+ CallerNode->removeCallEdgeTo(CalleeNode);
+
+ // Since we inlined all uninlinable call sites in the callee into the
+ // caller, add edges from the caller to all of the callees of the
+ // callee.
+ for (CallGraphNode::iterator I = CalleeNode->begin(),
+ E = CalleeNode->end(); I != E; ++I)
+ CallerNode->addCalledFunction(*I);
+ // If the only remaining use of the function is a dead constant
+ // pointer ref, remove it.
if (Callee->hasOneUse())
if (ConstantPointerRef *CPR =
dyn_cast<ConstantPointerRef>(Callee->use_back()))
@@ -110,7 +124,12 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
if (I != SCCFunctions.end()) // Remove function from this SCC.
SCCFunctions.erase(I);
- Callee->getParent()->getFunctionList().erase(Callee);
+ // Remove any call graph edges from the callee to its callees.
+ while (CalleeNode->begin() != CalleeNode->end())
+ CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1));
+
+ // Removing the node for callee from the call graph and delete it.
+ delete CG.removeFunctionFromModule(CalleeNode);
++NumDeleted;
}
Changed = true;