[llvm-dev] Function to strip Module of all debug information

SANJAY SRIVALLABH SINGAPURAM via llvm-dev llvm-dev at lists.llvm.org
Sun Mar 19 08:41:13 PDT 2017


Hello,

I need to strip a Module of all debug information before sending it to
verifyModule (This is a Module meant for NVPTX code). I've been using
llvm::StripDebugInfo, but it doesn't strip some of the debug information.
Following is an output from Verifier::visitInstruction,

Cannot invoke an intrinsic other than donothing, patchpoint, statepoint,
coro_resume or coro_destroy
  store void (metadata, i64, metadata, metadata)* @llvm.dbg.value, void
(metadata, i64, metadata, metadata)** %polly_launch_0_param_7, align 8

Will the following change to lib/IR/DebugInfo.cpp help resolve the problem ?
@@ -312,7 +312,7 @@ bool llvm::StripDebugInfo(Module &M) {

     // We're stripping debug info, and without them, coverage information
     // doesn't quite make sense.
-    if (NMD->getName().startswith("llvm.dbg.") ||
+    if (NMD->getName().contains("llvm.dbg.") ||
         NMD->getName() == "llvm.gcov") {
       NMD->eraseFromParent();
       Changed = true

I'm not sure if NamedMDNodes are going to include instructions.

Although llvm::stripDebugInfo(Function &F) (called through StripDebugInfo
on Functions present in the Module) removes DbgInfoIntrinsic instructions,
it seems to miss this store instruction. Does this store to a
@llvm.dbg.value count as a DbgInfoIntrinsic instruction ?

Please suggest a function to strip even this instruction.

Also, what does storing something at a place pointed by a function pointer
mean in the context of a debug intrinsic ?

Thank You,
Sanjay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170319/3aadc6f2/attachment.html>


More information about the llvm-dev mailing list