[PATCH] D46815: [DbgInfo] Fix StripDebugInfo

Son Tuan Vu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 05:19:57 PDT 2018


tyb0807 updated this revision to Diff 146793.
tyb0807 marked 2 inline comments as done.
tyb0807 added a comment.

Address review comments. Other comments inlined


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,17 @@
   if (GVMaterializer *Materializer = M.getMaterializer())
     Materializer->setStripDebugInfo();
 
+  StringRef DbgIntrinsics[3] = {"llvm.dbg.value",
+                                "llvm.dbg.declare",
+                                "llvm.dbg.addr"};
+  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,11 @@
+; RUN: opt -S -enable-debugify -strip-debugify <%s | FileCheck %s
+
+; CHECK-LABEL: foo
+define i32 @foo(i8 signext %arg) {
+entry:
+  %conv = sext i8 %arg to i32
+  %add = add nsw i32 %conv, 1
+  ret i32 %add
+}
+
+; CHECK-NOT: llvm.dbg.
Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -202,6 +202,10 @@
 static cl::opt<bool>
 AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
 
+static cl::opt<bool>
+StripDebugify("strip-debugify",
+           cl::desc("Strip debugify metadata in enable-debugify after check."));
+
 static cl::opt<bool> EnableDebugify(
     "enable-debugify",
     cl::desc(
@@ -756,7 +760,7 @@
     Passes.add(createVerifierPass());
 
   if (AddOneTimeDebugifyPasses)
-    Passes.add(createCheckDebugifyModulePass(false));
+    Passes.add(createCheckDebugifyModulePass(StripDebugify));
 
   // 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.146793.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180515/4fab9b7b/attachment.bin>


More information about the llvm-commits mailing list