From 45517baf9f188baa7f9aaa69d3146645c9c4af04 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 18 Oct 2005 06:29:22 +0000 Subject: 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. llvm-svn: 23783 --- llvm/lib/Transforms/IPO/Internalize.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Transforms/IPO') diff --git a/llvm/lib/Transforms/IPO/Internalize.cpp b/llvm/lib/Transforms/IPO/Internalize.cpp index 85a7abd1014..eeee63b9893 100644 --- a/llvm/lib/Transforms/IPO/Internalize.cpp +++ b/llvm/lib/Transforms/IPO/Internalize.cpp @@ -41,12 +41,16 @@ namespace { class InternalizePass : public ModulePass { std::set 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 X("internalize", "Internalize Global Symbols"); } // end anonymous namespace -ModulePass *llvm::createInternalizePass() { - return new InternalizePass(); +ModulePass *llvm::createInternalizePass(bool InternalizeEverything) { + return new InternalizePass(InternalizeEverything); } -- cgit v1.2.3