[llvm-commits] [llvm] r59208 - /llvm/trunk/lib/Transforms/IPO/StripSymbols.cpp
Chris Lattner
clattner at apple.com
Sat Nov 15 22:36:30 PST 2008
On Nov 12, 2008, at 5:28 PM, Devang Patel wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=59208&view=rev
> Log:
> Really remove all debug information.
Ok.
> @@ -213,8 +220,30 @@
> Declare->eraseFromParent();
> }
>
> + // Delete all dbg variables.
> + const Type *DbgVTy = M.getTypeByName("llvm.dbg.variable.type");
> + const Type *DbgGVTy =
> M.getTypeByName("llvm.dbg.global_variable.type");
This isn't safe. You can depend on the names of non-internal globals,
but not on the names of types. Type names can be stripped out. Also,
we may add new type names for debug info in the future.
> + if (DbgVTy || DbgGVTy)
> + for (Module::global_iterator I = M.global_begin(), E =
> M.global_end();
> + I != E; ++I)
> + if (GlobalVariable *GV = dyn_cast<GlobalVariable>(I))
> + if (GV->hasName() && GV->use_empty()
> + && !strncmp(GV->getNameStart(), "llvm.dbg", 8)
> + && (GV->getType()->getElementType() == DbgVTy
> + || GV->getType()->getElementType() == DbgGVTy))
> + DeadGlobals.push_back(GV);
> +
I don't think that matching on the names is really a sound way to go.
How about just looping over all the globals, removing dead globals in
the llvm.metadata section?
-Chris
More information about the llvm-commits
mailing list