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

Chris Lattner sabre at nondot.org
Tue Feb 6 22:23:03 PST 2007



Changes in directory llvm/lib/Transforms/IPO:

StripSymbols.cpp updated: 1.13 -> 1.14
---
Log message:

shrink vmcore by moving symbol table stripping support out of VMCore into
the one IPO pass that uses it.


---
Diffs of the changes:  (+23 -2)

 StripSymbols.cpp |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/IPO/StripSymbols.cpp
diff -u llvm/lib/Transforms/IPO/StripSymbols.cpp:1.13 llvm/lib/Transforms/IPO/StripSymbols.cpp:1.14
--- llvm/lib/Transforms/IPO/StripSymbols.cpp:1.13	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/StripSymbols.cpp	Wed Feb  7 00:22:45 2007
@@ -73,6 +73,27 @@
   }
 }
 
+// Strip the symbol table of its names.
+//
+static void StripSymtab(ValueSymbolTable &ST) {
+  for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
+    Value *V = VI->second;
+    ++VI;
+    if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasInternalLinkage()) {
+      // Set name to "", removing from symbol table!
+      V->setName("");
+    }
+  }
+}
+
+// Strip the symbol table of its names.
+static void StripTypeSymtab(TypeSymbolTable &ST) {
+  for (TypeSymbolTable::iterator TI = ST.begin(), E = ST.end(); TI != E; )
+    ST.remove(TI++);
+}
+
+
+
 bool StripSymbols::runOnModule(Module &M) {
   // If we're not just stripping debug info, strip all symbols from the
   // functions and the names from any internal globals.
@@ -85,11 +106,11 @@
     for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
       if (I->hasInternalLinkage())
         I->setName("");     // Internal symbols can't participate in linkage
-      I->getValueSymbolTable().strip();
+      StripSymtab(I->getValueSymbolTable());
     }
     
     // Remove all names from types.
-    M.getTypeSymbolTable().strip();
+    StripTypeSymtab(M.getTypeSymbolTable());
   }
 
   // Strip debug info in the module if it exists.  To do this, we remove






More information about the llvm-commits mailing list