[PATCH] D46815: [DbgInfo] Fix StripDebugInfo

Son Tuan Vu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 02:37:15 PDT 2018


tyb0807 updated this revision to Diff 147452.
tyb0807 marked an inline comment as done.
tyb0807 added a comment.

Context added


https://reviews.llvm.org/D46815

Files:
  lib/IR/DebugInfo.cpp
  test/DebugInfo/strip-intrinsic-dbg.ll
  tools/opt/opt.cpp


Index: lib/IR/DebugInfo.cpp
===================================================================
--- lib/IR/DebugInfo.cpp
+++ lib/IR/DebugInfo.cpp
@@ -380,6 +380,16 @@
   if (GVMaterializer *Materializer = M.getMaterializer())
     Materializer->setStripDebugInfo();
 
+  StringRef DbgIntrinsics[] = {"llvm.dbg.value", "llvm.dbg.declare",
+                               "llvm.dbg.addr", "llvm.dbg.label"};
+  for (StringRef FuncName : DbgIntrinsics) {
+    auto *F = M.getFunction(FuncName);
+    if (!F)
+      continue;
+    F->eraseFromParent();
+    Changed = true;
+  }
+
   return Changed;
 }
 
Index: test/DebugInfo/strip-intrinsic-dbg.ll
===================================================================
--- test/DebugInfo/strip-intrinsic-dbg.ll
+++ test/DebugInfo/strip-intrinsic-dbg.ll
@@ -0,0 +1,7 @@
+; RUN: opt -S -strip-debug <%s | FileCheck %s
+
+; CHECK-NOT: llvm.dbg.
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+declare void @llvm.dbg.addr(metadata, metadata, metadata)
+declare void @llvm.dbg.label(metadata, metadata, metadata)
Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -756,7 +756,7 @@
     Passes.add(createVerifierPass());
 
   if (AddOneTimeDebugifyPasses)
-    Passes.add(createCheckDebugifyModulePass(false));
+    Passes.add(createCheckDebugifyModulePass(StripDebug));
 
   // In run twice mode, we want to make sure the output is bit-by-bit
   // equivalent if we run the pass manager again, so setup two buffers and


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46815.147452.patch
Type: text/x-patch
Size: 1623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180518/9a7e94b0/attachment.bin>


More information about the llvm-commits mailing list