Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-04-20 20:20:59 +00:00
parent 7be1e0b478
commit 5ad2b1d544

View File

@ -120,14 +120,18 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
(Callee->hasInternalLinkage() || Callee->hasLinkOnceLinkage())) { (Callee->hasInternalLinkage() || Callee->hasLinkOnceLinkage())) {
DEBUG(std::cerr << " -> Deleting dead function: " DEBUG(std::cerr << " -> Deleting dead function: "
<< Callee->getName() << "\n"); << Callee->getName() << "\n");
std::set<Function*>::iterator I = SCCFunctions.find(Callee); SCCFunctions.erase(Callee); // Remove function from this SCC.
if (I != SCCFunctions.end()) // Remove function from this SCC.
SCCFunctions.erase(I);
// Remove any call graph edges from the callee to its callees. // Remove any call graph edges from the callee to its callees.
while (CalleeNode->begin() != CalleeNode->end()) while (CalleeNode->begin() != CalleeNode->end())
CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1)); CalleeNode->removeCallEdgeTo(*(CalleeNode->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 (!Callee->hasInternalLinkage())
CG.getExternalCallingNode()->removeCallEdgeTo(CalleeNode);
// Removing the node for callee from the call graph and delete it. // Removing the node for callee from the call graph and delete it.
delete CG.removeFunctionFromModule(CalleeNode); delete CG.removeFunctionFromModule(CalleeNode);
++NumDeleted; ++NumDeleted;