[PATCH] D25689: [opt] Strip coverage if debug info is not present

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 13:14:54 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL284418: [opt] Strip coverage if debug info is not present. (authored by davide).

Changed prior to commit:
  https://reviews.llvm.org/D25689?vs=74879&id=74889#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25689

Files:
  llvm/trunk/lib/IR/DebugInfo.cpp
  llvm/trunk/test/Transforms/StripSymbols/strip-cov.ll


Index: llvm/trunk/lib/IR/DebugInfo.cpp
===================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp
+++ llvm/trunk/lib/IR/DebugInfo.cpp
@@ -272,7 +272,11 @@
          NME = M.named_metadata_end(); NMI != NME;) {
     NamedMDNode *NMD = &*NMI;
     ++NMI;
-    if (NMD->getName().startswith("llvm.dbg.")) {
+
+    // We're stripping debug info, and without them, coverage information
+    // doesn't quite make sense.
+    if (NMD->getName().startswith("llvm.dbg.") ||
+        NMD->getName() == "llvm.gcov") {
       NMD->eraseFromParent();
       Changed = true;
     }
Index: llvm/trunk/test/Transforms/StripSymbols/strip-cov.ll
===================================================================
--- llvm/trunk/test/Transforms/StripSymbols/strip-cov.ll
+++ llvm/trunk/test/Transforms/StripSymbols/strip-cov.ll
@@ -0,0 +1,20 @@
+; RUN: opt -S %s -strip -o - | FileCheck %s
+
+; CHECK-NOT: !llvm.dbg.cu
+; CHECK-NOT: !llvm.gcov
+
+; CHECK: !llvm.module.flags = !{!0}
+; CHECK: !0 = !{i32 2, !"Debug Info Version", i32 3}
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!llvm.gcov = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 284352) (llvm/trunk 284353)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
+!1 = !DIFile(filename: "/dev/null", directory: "/home/davide/work/llvm/build/bin")
+!2 = !{}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{!"/scratch/patatino/build/bin/null.gcno", !"/scratch/patatino/build/bin/null.gcda", !0}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25689.74889.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161017/05089507/attachment.bin>


More information about the llvm-commits mailing list