xref: /llvm-project/llvm/test/DebugInfo/Generic/debug-label.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc -O0 -filetype=obj -o - %s | llvm-dwarfdump -v - | FileCheck %s
2;
3; CHECK: .debug_info contents:
4; CHECK: DW_TAG_label
5; CHECK-NEXT: DW_AT_name {{.*}}"top"
6; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] {{.*}}debug-label.c
7; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] {{.*}}4
8; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] {{.*}}{{0x[0-9a-f]+}}
9; CHECK: DW_TAG_label
10; CHECK-NEXT: DW_AT_name {{.*}}"done"
11; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] {{.*}}debug-label.c
12; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] {{.*}}7
13; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] {{.*}}{{0x[0-9a-f]+}}
14; CHECK-NOT: DW_AT_name {{.*}}"top"
15;
16; RUN: llc -O0 -o - %s | FileCheck %s -check-prefix=ASM
17;
18; ASM: [[TOP_LOW_PC:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}DEBUG_LABEL: foo:top
19; ASM: [[DONE_LOW_PC:[.0-9a-zA-Z]+]]:{{[[:space:]].*}}DEBUG_LABEL: foo:done
20; ASM-LABEL: {{debug_info|dwinfo}}
21; ASM: DW_TAG_label
22; ASM-NEXT: DW_AT_name
23; ASM: 1 {{.*}} DW_AT_decl_file
24; ASM-NEXT: 4 {{.*}} DW_AT_decl_line
25; ASM-NEXT: [[TOP_LOW_PC]]{{.*}} DW_AT_low_pc
26; ASM: DW_TAG_label
27; ASM-NEXT: DW_AT_name
28; ASM: 1 {{.*}} DW_AT_decl_file
29; ASM-NEXT: 7 {{.*}} DW_AT_decl_line
30; ASM-NEXT: [[DONE_LOW_PC]]{{.*}} DW_AT_low_pc
31
32source_filename = "debug-label.c"
33
34define dso_local i32 @foo(i32 %a, i32 %b) !dbg !6 {
35entry:
36  %a.addr = alloca i32, align 4
37  %b.addr = alloca i32, align 4
38  %sum = alloca i32, align 4
39  store i32 %a, ptr %a.addr, align 4
40  store i32 %b, ptr %b.addr, align 4
41  br label %top
42
43top:
44  call void @llvm.dbg.label(metadata !10), !dbg !11
45  %0 = load i32, ptr %a.addr, align 4
46  %1 = load i32, ptr %b.addr, align 4
47  %add = add nsw i32 %0, %1
48  store i32 %add, ptr %sum, align 4
49  br label %done
50
51done:
52  call void @llvm.dbg.label(metadata !12), !dbg !13
53  %2 = load i32, ptr %sum, align 4
54  ret i32 %2, !dbg !14
55}
56
57declare void @llvm.dbg.label(metadata)
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!4}
61
62!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, emissionKind: FullDebug, enums: !2)
63!1 = !DIFile(filename: "debug-label.c", directory: "./")
64!2 = !{}
65!3 = !{!10}
66!4 = !{i32 2, !"Debug Info Version", i32 3}
67!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, retainedNodes: !3)
68!7 = !DISubroutineType(types: !8)
69!8 = !{!9, !9, !9}
70!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
71!10 = !DILabel(scope: !6, name: "top", file: !1, line: 4)
72!11 = !DILocation(line: 4, column: 1, scope: !6)
73!12 = !DILabel(scope: !15, name: "done", file: !1, line: 7)
74!13 = !DILocation(line: 7, column: 1, scope: !6)
75!14 = !DILocation(line: 8, column: 3, scope: !6)
76!15 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !6)
77