diff options
author | Duncan Sands <baldrick@free.fr> | 2008-10-03 07:36:09 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-10-03 07:36:09 +0000 |
commit | a2582da44dbe7204aac49cdaeccfd4e77ff7c408 (patch) | |
tree | 38ad77e55802d1222daba3bfce1d8e96f786de68 /lib/Transforms | |
parent | dcb31e179000193c65b3f09b7138ef273dc3ce63 (diff) | |
download | external_llvm-a2582da44dbe7204aac49cdaeccfd4e77ff7c408.zip external_llvm-a2582da44dbe7204aac49cdaeccfd4e77ff7c408.tar.gz external_llvm-a2582da44dbe7204aac49cdaeccfd4e77ff7c408.tar.bz2 |
Teach internalize to preserve the callgraph.
Why? Because it was there!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/Internalize.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 47fe5fe..462daab 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "internalize" +#include "llvm/Analysis/CallGraph.h" #include "llvm/Transforms/IPO.h" #include "llvm/Pass.h" #include "llvm/Module.h" @@ -55,6 +56,7 @@ namespace { virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesCFG(); + AU.addPreserved<CallGraph>(); } }; } // end anonymous namespace @@ -96,6 +98,9 @@ void InternalizePass::LoadFile(const char *Filename) { } bool InternalizePass::runOnModule(Module &M) { + CallGraph *CG = getAnalysisToUpdate<CallGraph>(); + CallGraphNode *ExternalNode = CG ? CG->getExternalCallingNode() : 0; + if (ExternalNames.empty()) { // Return if we're not in 'all but main' mode and have no external api if (!AllButMain) @@ -120,6 +125,8 @@ bool InternalizePass::runOnModule(Module &M) { !I->hasInternalLinkage() && // Can't already have internal linkage !ExternalNames.count(I->getName())) {// Not marked to keep external? I->setLinkage(GlobalValue::InternalLinkage); + // Remove a callgraph edge from the external node to this function. + if (ExternalNode) ExternalNode->removeOneAbstractEdgeTo((*CG)[I]); Changed = true; ++NumFunctions; DOUT << "Internalizing func " << I->getName() << "\n"; |