xref: /llvm-project/llvm/test/DebugInfo/COFF/lines-bb-start.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: llc -O0 < %s | FileCheck %s
2; RUN: llc --try-experimental-debuginfo-iterators -O0 < %s | FileCheck %s
3
4source_filename = "t.c"
5target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
6target triple = "i386-pc-windows-msvc19.0.24215"
7
8@str_const = internal unnamed_addr constant [4 x i8] c"str\00", align 1
9
10declare i32 @puts(ptr)
11declare void @use_i32(ptr)
12declare void @llvm.dbg.value(metadata, metadata, metadata) nounwind readnone
13
14; We had a line info quality issue where the LEA for the string constant had no
15; location info, so the .cv_loc directive appeared after it. Now we have logic
16; that tries to emit the first valid location to the top of each MBB.
17
18define void @lea_str_loc(i1 %cond) !dbg !8 {
19entry:
20  br i1 %cond, label %if.then, label %if.end, !dbg !17
21
22if.then:                                          ; preds = %entry
23  br label %return, !dbg !18
24
25if.end:                                           ; preds = %entry
26  %call = call i32 @puts(ptr @str_const), !dbg !19
27  br label %return, !dbg !20
28
29return:                                           ; preds = %if.end, %if.then
30  ret void, !dbg !20
31}
32
33; The t.c:5 line marker should appear immediately after the BB label.
34
35; CHECK-LABEL: _lea_str_loc:
36; CHECK:         .cv_loc {{.*}} # t.c:4:5
37; CHECK:         jmp     LBB{{.*}}
38; CHECK: LBB0_{{.*}}:                                 # %if.end
39; CHECK-NEXT:    .cv_loc {{.*}} # t.c:5:3
40; CHECK-NEXT:    leal    _str_const, %[[reg:[^ ]*]]
41; CHECK-NEXT:    movl    %[[reg]], (%esp)
42; CHECK-NEXT:    calll   _puts
43
44define void @instr_no_loc(i1 %cond) !dbg !21 {
45entry:
46  br i1 %cond, label %if.then, label %if.end, !dbg !22
47
48if.then:                                          ; preds = %entry
49  br label %return, !dbg !23
50
51if.end:                                           ; preds = %entry
52  call void asm sideeffect "nop", ""()
53  %call = call i32 @puts(ptr @str_const), !dbg !24
54  br label %return, !dbg !25
55
56return:                                           ; preds = %if.end, %if.then
57  ret void, !dbg !25
58}
59
60; CHECK-LABEL: _instr_no_loc:
61; CHECK:         .cv_loc {{.*}} # t.c:4:5
62; CHECK:         jmp     LBB{{.*}}
63; CHECK: LBB1_{{.*}}:                                 # %if.end
64; CHECK-NEXT:    .cv_loc {{.*}} # t.c:5:3
65; CHECK-NEXT:    #APP
66; CHECK-NEXT:    nop
67; CHECK-NEXT:    #NO_APP
68; CHECK-NEXT:    leal    _str_const, %[[reg:[^ ]*]]
69; CHECK-NEXT:    movl    %[[reg]], (%esp)
70; CHECK-NEXT:    calll   _puts
71
72define void @lea_dbg_value(i1 %cond) !dbg !30 {
73entry:
74  %value = alloca i32
75  store i32 42, ptr %value
76  br i1 %cond, label %if.then, label %if.end, !dbg !31
77
78if.then:                                          ; preds = %entry
79  br label %return, !dbg !32
80
81if.end:                                           ; preds = %entry
82  call void @llvm.dbg.value(metadata ptr %value, metadata !35, metadata !13), !dbg !34
83  call void @use_i32(ptr %value), !dbg !33
84  br label %return, !dbg !34
85
86return:                                           ; preds = %if.end, %if.then
87  ret void, !dbg !34
88}
89
90; CHECK-LABEL: _lea_dbg_value:
91; CHECK:         .cv_loc {{.*}} # t.c:4:5
92; CHECK:         jmp     LBB{{.*}}
93; CHECK: LBB2_{{.*}}:                                 # %if.end
94; CHECK-NEXT: L{{.*}}:
95; CHECK-NEXT: DEBUG_VALUE: lea_dbg_value:
96; CHECK-NEXT:    .cv_loc {{.*}} # t.c:5:3
97; CHECK:         leal 4(%esp), %[[reg:[^ ]*]]
98; CHECK:         movl    %[[reg]], (%esp)
99; CHECK:         calll   _use_i32
100
101!llvm.dbg.cu = !{!0}
102!llvm.module.flags = !{!3, !4, !5, !6}
103!llvm.ident = !{!7}
104
105!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
106!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "b32df088e991f1996b4e4deb3855c14b")
107!2 = !{}
108!3 = !{i32 1, !"NumRegisterParameters", i32 0}
109!4 = !{i32 2, !"CodeView", i32 1}
110!5 = !{i32 2, !"Debug Info Version", i32 3}
111!6 = !{i32 1, !"wchar_size", i32 2}
112!7 = !{!"clang version 5.0.0 "}
113!8 = distinct !DISubprogram(name: "lea_str_loc", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
114!9 = !DISubroutineType(types: !10)
115!10 = !{null, !11}
116!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
117!13 = !DIExpression(DW_OP_deref)
118!14 = !DILocation(line: 2, column: 12, scope: !8)
119!15 = !DILocation(line: 3, column: 7, scope: !16)
120!16 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
121!17 = !DILocation(line: 3, column: 7, scope: !8)
122!18 = !DILocation(line: 4, column: 5, scope: !16)
123!19 = !DILocation(line: 5, column: 3, scope: !8)
124!20 = !DILocation(line: 6, column: 1, scope: !8)
125!21 = distinct !DISubprogram(name: "instr_no_loc", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
126!22 = !DILocation(line: 3, column: 7, scope: !21)
127!23 = !DILocation(line: 4, column: 5, scope: !21)
128!24 = !DILocation(line: 5, column: 3, scope: !21)
129!25 = !DILocation(line: 6, column: 1, scope: !21)
130!30 = distinct !DISubprogram(name: "lea_dbg_value", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
131!31 = !DILocation(line: 3, column: 7, scope: !30)
132!32 = !DILocation(line: 4, column: 5, scope: !30)
133!33 = !DILocation(line: 5, column: 3, scope: !30)
134!34 = !DILocation(line: 6, column: 1, scope: !30)
135!35 = !DILocalVariable(name: "v", scope: !30, file: !1, line: 3, type: !11)
136