[PATCH] D45043: [DebugInfo] Add test cases for generating debug info of labels.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 07:19:26 PDT 2018


HsiangKai created this revision.
HsiangKai added reviewers: rnk, chenwj.
Herald added subscribers: JDevlieghere, aprantl.

Repository:
  rL LLVM

https://reviews.llvm.org/D45043

Files:
  test/DebugInfo/debuglabel.ll


Index: test/DebugInfo/debuglabel.ll
===================================================================
--- /dev/null
+++ test/DebugInfo/debuglabel.ll
@@ -0,0 +1,88 @@
+; RUN: llc -O0 -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s
+;
+; CHECK: .debug_info contents:
+; CHECK: DW_TAG_label
+; CHECK-NEXT: DW_AT_name [DW_FORM_strp]
+; CHECK-SAME: top
+; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1]
+; CHECK-SAME: debuglabel.c
+; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1]
+; CHECK-SAME: 4
+; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
+; CHECK-SAME: {{0x[0-9a-f]+}}
+; CHECK: DW_TAG_label
+; CHECK-NEXT: DW_AT_name [DW_FORM_strp]
+; CHECK-SAME: done
+; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1]
+; CHECK-SAME: debuglabel.c
+; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1]
+; CHECK-SAME: 7
+; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
+; CHECK-SAME: {{0x[0-9a-f]+}}
+;
+; RUN: llc -O0 -o - %s | FileCheck %s -check-prefix=ASM
+;
+; ASM: [[TOP_LOW_PC:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}DEBUG_LABEL: foo:top
+; ASM: [[DONE_LOW_PC:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}DEBUG_LABEL: foo:done
+; ASM-LABEL: .debug_str
+; ASM: [[TOP_LABEL:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}"top"
+; ASM: [[DONE_LABEL:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}"done"
+; ASM-LABEL: .debug_info
+; ASM: DW_TAG_label
+; ASM-NEXT: [[TOP_LABEL]] # DW_AT_name
+; ASM-NEXT: 1 # DW_AT_decl_file
+; ASM-NEXT: 4 # DW_AT_decl_line
+; ASM-NEXT: [[TOP_LOW_PC]] # DW_AT_low_pc
+; ASM: DW_TAG_label
+; ASM-NEXT: [[DONE_LABEL]] # DW_AT_name
+; ASM-NEXT: 1 # DW_AT_decl_file
+; ASM-NEXT: 7 # DW_AT_decl_line
+; ASM-NEXT: [[DONE_LOW_PC]] # DW_AT_low_pc
+
+source_filename = "debuglabel.c"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define dso_local i32 @foo(i32 %a, i32 %b) !dbg !6 {
+entry:
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  %sum = alloca i32, align 4
+  store i32 %a, i32* %a.addr, align 4
+  store i32 %b, i32* %b.addr, align 4
+  br label %top
+
+top:
+  call void @llvm.dbg.label(metadata !10), !dbg !11
+  %0 = load i32, i32* %a.addr, align 4
+  %1 = load i32, i32* %b.addr, align 4
+  %add = add nsw i32 %0, %1
+  store i32 %add, i32* %sum, align 4
+  br label %done
+
+done:
+  call void @llvm.dbg.label(metadata !12), !dbg !13
+  %2 = load i32, i32* %sum, align 4
+  ret i32 %2, !dbg !14
+}
+
+declare void @llvm.dbg.label(metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "debuglabel.c", directory: "./")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!7 = !DISubroutineType(types: !8)
+!8 = !{!9, !9, !9}
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!10 = !DILabel(scope: !6, name: "top", file: !1, line: 4)
+!11 = !DILocation(line: 4, column: 1, scope: !6)
+!12 = !DILabel(scope: !6, name: "done", file: !1, line: 7)
+!13 = !DILocation(line: 7, column: 1, scope: !6)
+!14 = !DILocation(line: 8, column: 3, scope: !6)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45043.140246.patch
Type: text/x-patch
Size: 3370 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/a4e982cb/attachment.bin>


More information about the llvm-commits mailing list