[PATCH] D46815: [DbgInfo] Fix StripDebugInfo

Son Tuan Vu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 14:25:39 PDT 2018


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

The test is now simplified. Please tell me if you really want to remove -strip-debugify option and use -strip-debug instead.

Thanks for your time


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,18 @@
   if (GVMaterializer *Materializer = M.getMaterializer())
     Materializer->setStripDebugInfo();
 
+  StringRef DbgIntrinsics[4] = {"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
@@ -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.146917.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180515/152341e8/attachment.bin>


More information about the llvm-commits mailing list