summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-08-08 03:29:50 +0000
committerChris Lattner <sabre@nondot.org>2004-08-08 03:29:50 +0000
commit54970c032815edadb1b2988ea33f5a1173e5b29c (patch)
tree47e55084e062a7fc89f08aa026068524cc6622bd /lib/Transforms
parentaf8a42445c99d2d733caf1f9ef3e3b53827613d5 (diff)
downloadllvm-54970c032815edadb1b2988ea33f5a1173e5b29c.tar.gz
llvm-54970c032815edadb1b2988ea33f5a1173e5b29c.tar.bz2
llvm-54970c032815edadb1b2988ea33f5a1173e5b29c.tar.xz
Fix another really nasty regression that Anshu pointed out. In cases where
dangling constant users were removed from a function, causing it to be dead, we never removed the call graph edge from the external node to the function. In most cases, this didn't cause a problem (by luck). This should definitely go into 1.3 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/Inliner.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index a962141052..f0cb03d7b1 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -54,8 +54,8 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
E = CalleeNode->end(); I != E; ++I)
CallerNode->addCalledFunction(*I);
- // If we inlined the last possible call site to the function,
- // delete the function body now.
+ // If we inlined the last possible call site to the function, delete the
+ // function body now.
if (Callee->use_empty() && Callee->hasInternalLinkage() &&
!SCCFunctions.count(Callee)) {
DEBUG(std::cerr << " -> Deleting dead function: "
@@ -64,7 +64,7 @@ static bool InlineCallIfPossible(CallSite CS, CallGraph &CG,
// 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;
@@ -167,27 +167,27 @@ bool Inliner::doFinalization(CallGraph &CG) {
// from the program. Insert the dead ones in the FunctionsToRemove set.
for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) {
CallGraphNode *CGN = I->second;
- Function *F = CGN ? CGN->getFunction() : 0;
-
- // If the only remaining users of the function are dead constants,
- // remove them.
- if (F) F->removeDeadConstantUsers();
-
- if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
- F->use_empty()) {
-
- // Remove any call graph edges from the function to its callees.
- while (CGN->begin() != CGN->end())
- CGN->removeCallEdgeTo(*(CGN->end()-1));
-
- // If the function has external linkage (basically if it's a linkonce
- // function) remove the edge from the external node to the callee
- // node.
- if (!F->hasInternalLinkage())
- CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
-
- // Removing the node for callee from the call graph and delete it.
- FunctionsToRemove.insert(CGN);
+ if (Function *F = CGN ? CGN->getFunction() : 0) {
+ // If the only remaining users of the function are dead constants,
+ // remove them.
+ bool HadDeadConstantUsers = !F->use_empty();
+ F->removeDeadConstantUsers();
+
+ if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
+ F->use_empty()) {
+ // Remove any call graph edges from the function to its callees.
+ while (CGN->begin() != CGN->end())
+ CGN->removeCallEdgeTo(*(CGN->end()-1));
+
+ // If the function has external linkage (basically if it's a linkonce
+ // function) remove the edge from the external node to the callee
+ // node.
+ if (!F->hasInternalLinkage() || HadDeadConstantUsers)
+ CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
+
+ // Removing the node for callee from the call graph and delete it.
+ FunctionsToRemove.insert(CGN);
+ }
}
}