aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-18 06:29:22 +0000
committerChris Lattner <sabre@nondot.org>2005-10-18 06:29:22 +0000
commita27ea769eb6f8be437ae1ff28ff49018a578f019 (patch)
tree9d0fd4ca549bf4a7dce1287befd48213be61393c
parentf9c6105a784f2f0ef683de007b25decb61ab5502 (diff)
Add an option to this pass. If it is set, we are allowed to internalize
all but main. If it's not set, we can still internalize, but only if an explicit symbol list is provided. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23783 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/Internalize.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp
index 85a7abd101..eeee63b989 100644
--- a/lib/Transforms/IPO/Internalize.cpp
+++ b/lib/Transforms/IPO/Internalize.cpp
@@ -41,12 +41,16 @@ namespace {
class InternalizePass : public ModulePass {
std::set<std::string> ExternalNames;
+ bool DontInternalize;
public:
- InternalizePass() {
+ InternalizePass(bool InternalizeEverything = true) : DontInternalize(false){
if (!APIFile.empty()) // If a filename is specified, use it
LoadFile(APIFile.c_str());
- else // Else, if a list is specified, use it.
+ else if (!APIList.empty()) // Else, if a list is specified, use it.
ExternalNames.insert(APIList.begin(), APIList.end());
+ else if (!InternalizeEverything)
+ // Finally, if we're allowed to, internalize all but main.
+ DontInternalize = true;
}
void LoadFile(const char *Filename) {
@@ -66,6 +70,8 @@ namespace {
}
virtual bool runOnModule(Module &M) {
+ if (DontInternalize) return false;
+
// If no list or file of symbols was specified, check to see if there is a
// "main" symbol defined in the module. If so, use it, otherwise do not
// internalize the module, it must be a library or something.
@@ -117,6 +123,6 @@ namespace {
RegisterOpt<InternalizePass> X("internalize", "Internalize Global Symbols");
} // end anonymous namespace
-ModulePass *llvm::createInternalizePass() {
- return new InternalizePass();
+ModulePass *llvm::createInternalizePass(bool InternalizeEverything) {
+ return new InternalizePass(InternalizeEverything);
}