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