diff options
author | Chris Lattner <sabre@nondot.org> | 2010-04-20 00:46:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-04-20 00:46:50 +0000 |
commit | eae220259fca393adc874ed41e3930011047beb7 (patch) | |
tree | 698cbbe993f16ec1e79ef85b0925c1d1c7234f3e /lib/Transforms/IPO/ArgumentPromotion.cpp | |
parent | 084751cd16c3b8017b5a237bd2575b65a6543f79 (diff) | |
download | external_llvm-eae220259fca393adc874ed41e3930011047beb7.zip external_llvm-eae220259fca393adc874ed41e3930011047beb7.tar.gz external_llvm-eae220259fca393adc874ed41e3930011047beb7.tar.bz2 |
Fix rdar://7879828 - crash in CallGraph, a self host issue.
Arg promotion was deleting call graph nodes that still had references
from the 'indirect' CGN. Like the inliner, it should only delete the
function if all references are gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r-- | lib/Transforms/IPO/ArgumentPromotion.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 8cca4c6..89f213e 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -105,7 +105,7 @@ bool ArgPromotion::runOnSCC(CallGraphSCC &SCC) { } Changed |= LocalChange; // Remember that we changed something. } while (LocalChange); - + return Changed; } @@ -874,8 +874,14 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F, NF_CGN->stealCalledFunctionsFrom(CG[F]); - // Now that the old function is dead, delete it. - delete CG.removeFunctionFromModule(F); + // Now that the old function is dead, delete it. If there is a dangling + // reference to the CallgraphNode, just leave the dead function around for + // someone else to nuke. + CallGraphNode *CGN = CG[F]; + if (CGN->getNumReferences() == 0) + delete CG.removeFunctionFromModule(CGN); + else + F->setLinkage(Function::ExternalLinkage); return NF_CGN; } |