From 49d64927e1920e583c2366e50353426ad17e6e72 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 2 Mar 2009 22:50:58 +0000 Subject: [PATCH] Remove all dbg symobls, including those with circular references. This is ugly, but I can't figure out a quick way out of this. llvm-svn: 65889 --- llvm/lib/Transforms/IPO/StripSymbols.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/StripSymbols.cpp b/llvm/lib/Transforms/IPO/StripSymbols.cpp index 47a18e25283b..3906b5111ec3 100644 --- a/llvm/lib/Transforms/IPO/StripSymbols.cpp +++ b/llvm/lib/Transforms/IPO/StripSymbols.cpp @@ -185,6 +185,21 @@ bool StripSymbolNames(Module &M, bool PreserveDbgInfo) { // llvm.dbg.region.end calls, and any globals they point to if now dead. bool StripDebugInfo(Module &M) { + SmallPtrSet 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(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 @@ bool StripDebugInfo(Module &M) { Declare->eraseFromParent(); } - SmallPtrSet 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?