1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=ASM
2 ; RUN: llc -mtriple=x86_64-windows-msvc < %s -filetype=obj | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
4 ; This test attempts to exercise gaps in local variables. The local variable 'p'
5 ; will end up in some CSR (esi), which will be used in both the BB scheduled
6 ; discontiguously out of line and the normal return BB. The best way to encode
7 ; this is to use a LocalVariableAddrGap. If the gap is too large, multiple
8 ; ranges should be emitted.
10 ; Source to regenerate:
14 ; void __declspec(noreturn) call_noreturn(int);
18 ; if (barrier()) // Unlikely, will be placed after return
31 ; ASM: testl %eax, %eax
34 ; ASM: movl %eax, %esi
35 ; ASM: [[p_b1:\.Ltmp[0-9]+]]:
36 ; ASM: #DEBUG_VALUE: p <- $esi
38 ; ASM: movl %esi, %ecx
39 ; ASM: testl %eax, %eax
41 ; ASM: # %bb.2: # %if.end
42 ; ASM: #DEBUG_VALUE: p <- $esi
45 ; ASM: [[p_e1:\.Ltmp[0-9]+]]:
46 ; ASM: .LBB0_3: # %if.else
48 ; ASM: .LBB0_4: # %if.end6
49 ; ASM: xorl %eax, %eax
53 ; ASM: .LBB0_5: # %if.then4
54 ; ASM: [[p_b2:\.Ltmp[0-9]+]]:
55 ; ASM: #DEBUG_VALUE: p <- $esi
56 ; ASM: callq call_noreturn
60 ; ASM: .short {{.*}} # Record length
61 ; ASM: .short 4414 # Record kind: S_LOCAL
62 ; ASM: .long 116 # TypeIndex
63 ; ASM: .short 0 # Flags
65 ; ASM: .cv_def_range [[p_b1]] [[p_e1]] [[p_b2]] .Lfunc_end0, reg, 23
66 ; ASM: .short 2 # Record length
67 ; ASM: .short 4431 # Record kind: S_PROC_ID_END
70 ; OBJ: Type: int (0x74)
74 ; OBJ: DefRangeRegisterSym {
76 ; OBJ-NEXT: Register: ESI (0x17)
77 ; OBJ-NEXT: MayHaveNoName: 0
78 ; OBJ-NEXT: LocalVariableAddrRange {
79 ; OBJ-NEXT: OffsetStart: .text+0x{{.*}}
80 ; OBJ-NEXT: ISectStart: 0x0
81 ; OBJ-NEXT: Range: 0x{{.*}}
83 ; OBJ-NEXT: LocalVariableAddrGap [
84 ; OBJ-NEXT: GapStartOffset: 0x{{.*}}
85 ; OBJ-NEXT: Range: 0x{{.*}}
90 source_filename = "t.cpp"
91 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
92 target triple = "x86_64-pc-windows-msvc19.0.24210"
94 ; Function Attrs: nounwind uwtable
95 define i32 @f() local_unnamed_addr #0 !dbg !7 {
97 %call = tail call i32 bitcast (i32 (...)* @barrier to i32 ()*)() #4, !dbg !15
98 %tobool = icmp eq i32 %call, 0, !dbg !15
99 br i1 %tobool, label %if.else, label %if.then, !dbg !16
101 if.then: ; preds = %entry
102 %call1 = tail call i32 bitcast (i32 (...)* @vardef to i32 ()*)() #4, !dbg !17
103 tail call void @llvm.dbg.value(metadata i32 %call1, metadata !12, metadata !18), !dbg !19
104 %call2 = tail call i32 bitcast (i32 (...)* @barrier to i32 ()*)() #4, !dbg !20
105 %tobool3 = icmp eq i32 %call2, 0, !dbg !20
106 br i1 %tobool3, label %if.end, label %if.then4, !dbg !22
108 if.then4: ; preds = %if.then
109 tail call void @call_noreturn(i32 %call1) #5, !dbg !23
110 unreachable, !dbg !23
112 if.end: ; preds = %if.then
113 tail call void @use(i32 %call1) #4, !dbg !24
114 br label %if.end6, !dbg !25
116 if.else: ; preds = %entry
117 %call5 = tail call i32 bitcast (i32 (...)* @barrier to i32 ()*)() #4, !dbg !26
120 if.end6: ; preds = %if.else, %if.end
124 declare i32 @barrier(...) local_unnamed_addr #1
126 declare i32 @vardef(...) local_unnamed_addr #1
128 ; Function Attrs: noreturn
129 declare void @call_noreturn(i32) local_unnamed_addr #2
131 declare void @use(i32) local_unnamed_addr #1
133 ; Function Attrs: nounwind readnone
134 declare void @llvm.dbg.value(metadata, metadata, metadata) #3
136 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
137 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
138 attributes #2 = { noreturn "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
139 attributes #3 = { nounwind readnone }
140 attributes #4 = { nounwind }
141 attributes #5 = { noreturn nounwind }
144 !llvm.module.flags = !{!3, !4, !5}
147 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
148 !1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm\5Cbuild")
150 !3 = !{i32 2, !"CodeView", i32 1}
151 !4 = !{i32 2, !"Debug Info Version", i32 3}
152 !5 = !{i32 1, !"PIC Level", i32 2}
153 !6 = !{!"clang version 4.0.0 "}
154 !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 19, type: !8, isLocal: false, isDefinition: true, scopeLine: 19, isOptimized: true, unit: !0, retainedNodes: !11)
155 !8 = !DISubroutineType(types: !9)
157 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
159 !12 = !DILocalVariable(name: "p", scope: !13, file: !1, line: 21, type: !10)
160 !13 = distinct !DILexicalBlock(scope: !14, file: !1, line: 20, column: 18)
161 !14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 20, column: 7)
162 !15 = !DILocation(line: 20, column: 7, scope: !14)
163 !16 = !DILocation(line: 20, column: 7, scope: !7)
164 !17 = !DILocation(line: 21, column: 13, scope: !13)
165 !18 = !DIExpression()
166 !19 = !DILocation(line: 21, column: 9, scope: !13)
167 !20 = !DILocation(line: 22, column: 9, scope: !21)
168 !21 = distinct !DILexicalBlock(scope: !13, file: !1, line: 22, column: 9)
169 !22 = !DILocation(line: 22, column: 9, scope: !13)
170 !23 = !DILocation(line: 23, column: 7, scope: !21)
171 !24 = !DILocation(line: 24, column: 5, scope: !13)
172 !25 = !DILocation(line: 25, column: 3, scope: !13)
173 !26 = !DILocation(line: 26, column: 5, scope: !27)
174 !27 = distinct !DILexicalBlock(scope: !14, file: !1, line: 25, column: 10)
175 !28 = !DILocation(line: 28, column: 3, scope: !7)