[llvm-commits] CVS: llvm/lib/Transforms/IPO/Internalize.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Oct 17 23:29:33 PDT 2005



Changes in directory llvm/lib/Transforms/IPO:

Internalize.cpp updated: 1.25 -> 1.26
---
Log message:

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.


---
Diffs of the changes:  (+10 -4)

 Internalize.cpp |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.25 llvm/lib/Transforms/IPO/Internalize.cpp:1.26
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.25	Thu Apr 21 18:39:37 2005
+++ llvm/lib/Transforms/IPO/Internalize.cpp	Tue Oct 18 01:29:22 2005
@@ -41,12 +41,16 @@
 
   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 @@
     }
 
     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 @@
   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);
 }






More information about the llvm-commits mailing list