Skip to content
Snippets Groups Projects
Commit 6455c51a authored by Chris Lattner's avatar Chris Lattner
Browse files

Fix the inliner to always delete any edges from the external call node to

a function being deleted.  Due to optimizations done while inlining, there
can be edges from the external call node to a function node that were not
apparent any longer.

This fixes the compiler crash while compiling 175.vpr

llvm-svn: 16399
parent 824a2186
No related branches found
No related tags found
No related merge requests found
...@@ -168,22 +168,21 @@ bool Inliner::doFinalization(CallGraph &CG) { ...@@ -168,22 +168,21 @@ bool Inliner::doFinalization(CallGraph &CG) {
for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) { for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) {
CallGraphNode *CGN = I->second; CallGraphNode *CGN = I->second;
if (Function *F = CGN ? CGN->getFunction() : 0) { if (Function *F = CGN ? CGN->getFunction() : 0) {
// If the only remaining users of the function are dead constants, // If the only remaining users of the function are dead constants, remove
// remove them. // them.
bool HadDeadConstantUsers = !F->use_empty();
F->removeDeadConstantUsers(); F->removeDeadConstantUsers();
if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
F->use_empty()) { F->use_empty()) {
// Remove any call graph edges from the function to its callees. // Remove any call graph edges from the function to its callees.
while (CGN->begin() != CGN->end()) while (CGN->begin() != CGN->end())
CGN->removeCallEdgeTo(*(CGN->end()-1)); CGN->removeCallEdgeTo(*(CGN->end()-1));
// If the function has external linkage (basically if it's a linkonce // Remove any edges from the external node to the function's call graph
// function) remove the edge from the external node to the callee // node. These edges might have been made irrelegant due to
// node. // optimization of the program.
if (!F->hasInternalLinkage() || HadDeadConstantUsers) CG.getExternalCallingNode()->removeAnyCallEdgeTo(CGN);
CG.getExternalCallingNode()->removeCallEdgeTo(CGN);
// Removing the node for callee from the call graph and delete it. // Removing the node for callee from the call graph and delete it.
FunctionsToRemove.insert(CGN); FunctionsToRemove.insert(CGN);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment