[llvm-commits] [llvm] r65889 - /llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp

Devang Patel dpatel at apple.com
Mon Mar 2 14:50:58 PST 2009


Author: dpatel
Date: Mon Mar  2 16:50:58 2009
New Revision: 65889

URL: http://llvm.org/viewvc/llvm-project?rev=65889&view=rev
Log:
Remove all dbg symobls, including those with circular references.

This is ugly, but I can't figure out a quick way out of this.

Modified:
    llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp

Modified: llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp?rev=65889&r1=65888&r2=65889&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp Mon Mar  2 16:50:58 2009
@@ -185,6 +185,21 @@
 // llvm.dbg.region.end calls, and any globals they point to if now dead.
 bool StripDebugInfo(Module &M) {
 
+  SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
+  findUsedValues(M, llvmUsedValues);
+
+  // Delete all dbg variables.
+  for (Module::global_iterator I = M.global_begin(), E = M.global_end(); 
+       I != E; ++I) {
+    GlobalVariable *GV = dyn_cast<GlobalVariable>(I);
+    if (!GV) continue;
+    if (!GV->use_empty() && llvmUsedValues.count(I) == 0) {
+      if (strncmp(GV->getNameStart(), "llvm.dbg", 8) == 0) {
+        GV->replaceAllUsesWith(UndefValue::get(GV->getType()));
+      }
+    }
+  }
+
   Function *FuncStart = M.getFunction("llvm.dbg.func.start");
   Function *StopPoint = M.getFunction("llvm.dbg.stoppoint");
   Function *RegionStart = M.getFunction("llvm.dbg.region.start");
@@ -263,9 +278,6 @@
     Declare->eraseFromParent();
   }
 
-  SmallPtrSet<const GlobalValue*, 8> llvmUsedValues;
-  findUsedValues(M, llvmUsedValues);
-
   // llvm.dbg.compile_units and llvm.dbg.subprograms are marked as linkonce
   // but since we are removing all debug information, make them internal now.
   // FIXME: Use private linkage maybe?





More information about the llvm-commits mailing list