[PATCH] Add new debug kind LocTrackingOnly.

Diego Novillo dnovillo at google.com
Fri Jun 20 13:04:30 PDT 2014


Add missing test.

Instead of adding the new test I was working on, I opted to make a smaller
change and modify an existing one. We already had a test with debug info
in it. I changed it so it is missing llvm.dbg.cu.

The test now checks:

1- That a missing llvm.dbg.cu does not prevent line location tracking from
   emitting proper locations with -pass-remarks.

2- That the final output contain no debug information in it.

http://reviews.llvm.org/D4234

Files:
  include/llvm/IR/DIBuilder.h
  lib/IR/DIBuilder.cpp
  test/Transforms/LoopVectorize/X86/vectorization-remarks.ll

Index: include/llvm/IR/DIBuilder.h
===================================================================
--- include/llvm/IR/DIBuilder.h
+++ include/llvm/IR/DIBuilder.h
@@ -87,7 +87,7 @@
     public:
     explicit DIBuilder(Module &M);
     enum ComplexAddrKind { OpPlus=1, OpDeref };
-    enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
+    enum DebugEmissionKind { FullDebug=1, LineTablesOnly, LocTrackingOnly };
 
     /// finalize - Construct any deferred debug info descriptors.
     void finalize();
@@ -108,6 +108,7 @@
     ///                 Objective-C.
     /// @param SplitName The name of the file that we'll split debug info out
     ///                  into.
+    /// @param Kind     The kind of debug information to generate.
     DICompileUnit createCompileUnit(unsigned Lang, StringRef File,
                                     StringRef Dir, StringRef Producer,
                                     bool isOptimized, StringRef Flags,
Index: lib/IR/DIBuilder.cpp
===================================================================
--- lib/IR/DIBuilder.cpp
+++ lib/IR/DIBuilder.cpp
@@ -140,8 +140,14 @@
   MDNode *CUNode = MDNode::get(VMContext, Elts);
 
   // Create a named metadata so that it is easier to find cu in a module.
-  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
-  NMD->addOperand(CUNode);
+  // Note that we only generate this when the caller wants to actually
+  // emit debug information. When we are only interested in tracking
+  // source line locations throughout the backend, we prevent codegen from
+  // emitting debug info in the final output by not generating llvm.dbg.cu.
+  if (Kind != LocTrackingOnly) {
+    NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
+    NMD->addOperand(CUNode);
+  }
 
   return DICompileUnit(CUNode);
 }
Index: test/Transforms/LoopVectorize/X86/vectorization-remarks.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/vectorization-remarks.ll
+++ test/Transforms/LoopVectorize/X86/vectorization-remarks.ll
@@ -1,6 +1,13 @@
 ; RUN: opt < %s -loop-vectorize -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' 2>&1 | FileCheck -check-prefix=VECTORIZED %s
 ; RUN: opt < %s -loop-vectorize -force-vector-width=1 -force-vector-unroll=4 -mtriple=x86_64-unknown-linux -S -pass-remarks='.*vectorize.*' 2>&1 | FileCheck -check-prefix=UNROLLED %s
 
+; This code has all the !dbg annotations needed to track source line information,
+; but is missing the llvm.dbg.cu annotation. This prevents code generation from
+; emitting debug info in the final output.
+; RUN: llc -mtriple x86_64-pc-linux-gnu %s -o - | FileCheck -check-prefix=DEBUG-OUTPUT %s
+; DEBUG-OUTPUT-NOT: .loc
+; DEBUG-OUTPUT-NOT: {{.*}}.debug_info{{.*}}
+
 ; VECTORIZED: remark: {{.*}}.c:17:8: vectorized loop (vectorization factor: 4, unrolling interleave factor: 1)
 ; UNROLLED: remark: {{.*}}.c:17:8: unrolled with interleaving factor 4 (vectorization not beneficial)
 
@@ -37,11 +44,9 @@
 
 declare void @ibar(i32*) #1
 
-!llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!7, !8}
 !llvm.ident = !{!9}
 
-!0 = metadata !{i32 786449, metadata !1, i32 12, metadata !"clang version 3.5.0 ", i1 true, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 2} ; [ DW_TAG_compile_unit ] [./vectorization-remarks.c] [DW_LANG_C99]
 !1 = metadata !{metadata !"vectorization-remarks.c", metadata !"."}
 !2 = metadata !{}
 !3 = metadata !{metadata !4}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4234.10703.patch
Type: text/x-patch
Size: 3527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140620/aae7c5dc/attachment.bin>


More information about the llvm-commits mailing list