1 ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s
3 ; -- lexicablock.cxx begin ----------------------------------------------------
4 ; int main(int argc, char *argv[]) {
7 ; { // S_BLOCK32 not emitted because it has multiple address ranges.
10 ; if (__builtin_expect(argc != 1, 0)) { // S_BLOCK32 containing 'localC'
15 ; { // S_BLOCK32 containing 'localD'
20 ; { // S_BLOCK32 not emitted
21 ; { // S_BLOCK32 containing 'localE'
27 ; { // S_BLOCK32 containing 'localF'
31 ; { // S_BLOCK32 containing 'localG'
37 ; if (localA == 7) { // S_BLOCK32 containing 'localH'
42 ; return localA != 8 ? -1 : 0;
44 ; -- lexicalblock.cxx end -----------------------------------------------------
46 ; To regenerate the IR below:
47 ; $ clang -cc1 -triple i686-pc-windows -emit-llvm -o lexicalblock.tmp -debug-info-kind=limited -gcodeview lexicablock.cxx -O1 -disable-llvm-passes
48 ; $ opt -lower-expect -S -o lexicalblock.ll < lexicalblock.tmp
50 ; The commands above split the lexical block containing localB and localC into
51 ; two parts, thus creating multiple ranges for the containing lexical block
52 ; without optimizing out the whole thing.
54 ; CHECK: {{.*}}Proc{{.*}}Sym {
55 ; CHECK: DisplayName: main
58 ; CHECK: VarName: argc
61 ; CHECK: VarName: argv
64 ; CHECK: VarName: localA
67 ; CHECK: VarName: localB
70 ; CHECK: Kind: S_BLOCK32 {{.*}}
73 ; CHECK: ScopeEndSym {
74 ; CHECK: Kind: S_END {{.*}}
77 ; CHECK: Kind: S_BLOCK32 {{.*}}
80 ; CHECK: ScopeEndSym {
81 ; CHECK: Kind: S_END {{.*}}
84 ; CHECK: Kind: S_BLOCK32 {{.*}}
87 ; CHECK: ScopeEndSym {
90 ; CHECK: Kind: S_BLOCK32 {{.*}}
93 ; CHECK: ScopeEndSym {
94 ; CHECK: Kind: S_END {{.*}}
99 ; ModuleID = 'lexicalblock.cxx'
100 source_filename = "lexicalblock.cxx"
101 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
102 target triple = "i686-pc-windows-msvc"
104 ; Function Attrs: norecurse nounwind
105 define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {
107 %retval = alloca i32, align 4
108 %argv.addr = alloca i8**, align 4
109 %argc.addr = alloca i32, align 4
110 %localA = alloca i32, align 4
111 %localB = alloca i32, align 4
112 %localC = alloca i32, align 4
113 %localD = alloca i32, align 4
114 %localE = alloca i32, align 4
115 %localF = alloca i32, align 4
116 %localG = alloca i32, align 4
117 %localH = alloca i32, align 4
118 store i32 0, i32* %retval, align 4
119 store i8** %argv, i8*** %argv.addr, align 4, !tbaa !37
120 call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !17, metadata !DIExpression()), !dbg !41
121 store i32 %argc, i32* %argc.addr, align 4, !tbaa !42
122 call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !41
123 %0 = bitcast i32* %localA to i8*, !dbg !44
124 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #4, !dbg !44
125 call void @llvm.dbg.declare(metadata i32* %localA, metadata !19, metadata !DIExpression()), !dbg !44
126 store i32 1, i32* %localA, align 4, !dbg !44, !tbaa !42
127 %1 = bitcast i32* %localB to i8*, !dbg !45
128 call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #4, !dbg !45
129 call void @llvm.dbg.declare(metadata i32* %localB, metadata !20, metadata !DIExpression()), !dbg !45
130 store i32 2, i32* %localB, align 4, !dbg !45, !tbaa !42
131 %2 = load i32, i32* %argc.addr, align 4, !dbg !46, !tbaa !42
132 %cmp = icmp ne i32 %2, 1, !dbg !46
133 %conv = zext i1 %cmp to i32, !dbg !46
134 %tobool = icmp ne i32 %conv, 0, !dbg !46
135 br i1 %tobool, label %if.then, label %if.end, !dbg !46, !prof !47
137 if.then: ; preds = %entry
138 %3 = bitcast i32* %localC to i8*, !dbg !48
139 call void @llvm.lifetime.start.p0i8(i64 4, i8* %3) #4, !dbg !48
140 call void @llvm.dbg.declare(metadata i32* %localC, metadata !22, metadata !DIExpression()), !dbg !48
141 store i32 3, i32* %localC, align 4, !dbg !48, !tbaa !42
142 %4 = bitcast i32* %localC to i8*, !dbg !49
143 call void @llvm.lifetime.end.p0i8(i64 4, i8* %4) #4, !dbg !49
144 br label %if.end, !dbg !49
146 if.end: ; preds = %if.then, %entry
147 %5 = bitcast i32* %localB to i8*, !dbg !50
148 call void @llvm.lifetime.end.p0i8(i64 4, i8* %5) #4, !dbg !50
149 %6 = bitcast i32* %localD to i8*, !dbg !51
150 call void @llvm.lifetime.start.p0i8(i64 4, i8* %6) #4, !dbg !51
151 call void @llvm.dbg.declare(metadata i32* %localD, metadata !25, metadata !DIExpression()), !dbg !51
152 store i32 4, i32* %localD, align 4, !dbg !51, !tbaa !42
153 %7 = load i32, i32* %localD, align 4, !dbg !52, !tbaa !42
154 store i32 %7, i32* %localA, align 4, !dbg !52, !tbaa !42
155 %8 = bitcast i32* %localD to i8*, !dbg !53
156 call void @llvm.lifetime.end.p0i8(i64 4, i8* %8) #4, !dbg !53
157 %9 = bitcast i32* %localE to i8*, !dbg !54
158 call void @llvm.lifetime.start.p0i8(i64 4, i8* %9) #4, !dbg !54
159 call void @llvm.dbg.declare(metadata i32* %localE, metadata !27, metadata !DIExpression()), !dbg !54
160 store i32 5, i32* %localE, align 4, !dbg !54, !tbaa !42
161 %10 = load i32, i32* %localE, align 4, !dbg !55, !tbaa !42
162 store i32 %10, i32* %localA, align 4, !dbg !55, !tbaa !42
163 %11 = bitcast i32* %localE to i8*, !dbg !56
164 call void @llvm.lifetime.end.p0i8(i64 4, i8* %11) #4, !dbg !56
165 %12 = bitcast i32* %localF to i8*, !dbg !57
166 call void @llvm.lifetime.start.p0i8(i64 4, i8* %12) #4, !dbg !57
167 call void @llvm.dbg.declare(metadata i32* %localF, metadata !30, metadata !DIExpression()), !dbg !57
168 store i32 6, i32* %localF, align 4, !dbg !57, !tbaa !42
169 %13 = load i32, i32* %localF, align 4, !dbg !58, !tbaa !42
170 store i32 %13, i32* %localA, align 4, !dbg !58, !tbaa !42
171 %14 = bitcast i32* %localG to i8*, !dbg !59
172 call void @llvm.lifetime.start.p0i8(i64 4, i8* %14) #4, !dbg !59
173 call void @llvm.dbg.declare(metadata i32* %localG, metadata !32, metadata !DIExpression()), !dbg !59
174 store i32 7, i32* %localG, align 4, !dbg !59, !tbaa !42
175 %15 = load i32, i32* %localG, align 4, !dbg !60, !tbaa !42
176 store i32 %15, i32* %localA, align 4, !dbg !60, !tbaa !42
177 %16 = bitcast i32* %localG to i8*, !dbg !61
178 call void @llvm.lifetime.end.p0i8(i64 4, i8* %16) #4, !dbg !61
179 %17 = bitcast i32* %localF to i8*, !dbg !62
180 call void @llvm.lifetime.end.p0i8(i64 4, i8* %17) #4, !dbg !62
181 %18 = load i32, i32* %localA, align 4, !dbg !63, !tbaa !42
182 %cmp1 = icmp eq i32 %18, 7, !dbg !63
183 br i1 %cmp1, label %if.then2, label %if.end3, !dbg !63
185 if.then2: ; preds = %if.end
186 %19 = bitcast i32* %localH to i8*, !dbg !64
187 call void @llvm.lifetime.start.p0i8(i64 4, i8* %19) #4, !dbg !64
188 call void @llvm.dbg.declare(metadata i32* %localH, metadata !34, metadata !DIExpression()), !dbg !64
189 store i32 8, i32* %localH, align 4, !dbg !64, !tbaa !42
190 %20 = load i32, i32* %localH, align 4, !dbg !65, !tbaa !42
191 store i32 %20, i32* %localA, align 4, !dbg !65, !tbaa !42
192 %21 = bitcast i32* %localH to i8*, !dbg !66
193 call void @llvm.lifetime.end.p0i8(i64 4, i8* %21) #4, !dbg !66
194 br label %if.end3, !dbg !66
196 if.end3: ; preds = %if.then2, %if.end
197 %22 = load i32, i32* %localA, align 4, !dbg !67, !tbaa !42
198 %cmp4 = icmp ne i32 %22, 8, !dbg !67
199 %23 = zext i1 %cmp4 to i64, !dbg !67
200 %cond = select i1 %cmp4, i32 -1, i32 0, !dbg !67
201 %24 = bitcast i32* %localA to i8*, !dbg !68
202 call void @llvm.lifetime.end.p0i8(i64 4, i8* %24) #4, !dbg !68
203 ret i32 %cond, !dbg !67
206 ; Function Attrs: nounwind readnone speculatable
207 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
209 ; Function Attrs: argmemonly nounwind
210 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
212 ; Function Attrs: nounwind readnone
213 declare i32 @llvm.expect.i32(i32, i32) #3
215 ; Function Attrs: argmemonly nounwind
216 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
218 attributes #0 = { norecurse nounwind "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-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
219 attributes #1 = { nounwind readnone speculatable }
220 attributes #2 = { argmemonly nounwind }
221 attributes #3 = { nounwind readnone }
222 attributes #4 = { nounwind }
225 !llvm.module.flags = !{!3, !4, !5, !6}
228 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
229 !1 = !DIFile(filename: "<stdin>", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")
231 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
232 !4 = !{i32 2, !"CodeView", i32 1}
233 !5 = !{i32 2, !"Debug Info Version", i32 3}
234 !6 = !{i32 1, !"wchar_size", i32 2}
235 !7 = !{!"clang version 7.0.0 (trunk)"}
236 !8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16)
237 !9 = !DIFile(filename: "lexicalblock.cxx", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")
238 !10 = !DISubroutineType(types: !11)
239 !11 = !{!12, !12, !13}
240 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
241 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
242 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32)
243 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
244 !16 = !{!17, !18, !19, !20, !22, !25, !27, !30, !32, !34}
245 !17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 1, type: !13)
246 !18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 1, type: !12)
247 !19 = !DILocalVariable(name: "localA", scope: !8, file: !9, line: 2, type: !12)
248 !20 = !DILocalVariable(name: "localB", scope: !21, file: !9, line: 5, type: !12)
249 !21 = distinct !DILexicalBlock(scope: !8, file: !9, line: 4)
250 !22 = !DILocalVariable(name: "localC", scope: !23, file: !9, line: 8, type: !12)
251 !23 = distinct !DILexicalBlock(scope: !24, file: !9, line: 7)
252 !24 = distinct !DILexicalBlock(scope: !21, file: !9, line: 7)
253 !25 = !DILocalVariable(name: "localD", scope: !26, file: !9, line: 13, type: !12)
254 !26 = distinct !DILexicalBlock(scope: !8, file: !9, line: 12)
255 !27 = !DILocalVariable(name: "localE", scope: !28, file: !9, line: 19, type: !12)
256 !28 = distinct !DILexicalBlock(scope: !29, file: !9, line: 18)
257 !29 = distinct !DILexicalBlock(scope: !8, file: !9, line: 17)
258 !30 = !DILocalVariable(name: "localF", scope: !31, file: !9, line: 25, type: !12)
259 !31 = distinct !DILexicalBlock(scope: !8, file: !9, line: 24)
260 !32 = !DILocalVariable(name: "localG", scope: !33, file: !9, line: 29, type: !12)
261 !33 = distinct !DILexicalBlock(scope: !31, file: !9, line: 28)
262 !34 = !DILocalVariable(name: "localH", scope: !35, file: !9, line: 35, type: !12)
263 !35 = distinct !DILexicalBlock(scope: !36, file: !9, line: 34)
264 !36 = distinct !DILexicalBlock(scope: !8, file: !9, line: 34)
265 !37 = !{!38, !38, i64 0}
266 !38 = !{!"any pointer", !39, i64 0}
267 !39 = !{!"omnipotent char", !40, i64 0}
268 !40 = !{!"Simple C++ TBAA"}
269 !41 = !DILocation(line: 1, scope: !8)
270 !42 = !{!43, !43, i64 0}
271 !43 = !{!"int", !39, i64 0}
272 !44 = !DILocation(line: 2, scope: !8)
273 !45 = !DILocation(line: 5, scope: !21)
274 !46 = !DILocation(line: 7, scope: !21)
275 !47 = !{!"branch_weights", i32 1, i32 2000}
276 !48 = !DILocation(line: 8, scope: !23)
277 !49 = !DILocation(line: 9, scope: !23)
278 !50 = !DILocation(line: 10, scope: !21)
279 !51 = !DILocation(line: 13, scope: !26)
280 !52 = !DILocation(line: 14, scope: !26)
281 !53 = !DILocation(line: 15, scope: !26)
282 !54 = !DILocation(line: 19, scope: !28)
283 !55 = !DILocation(line: 20, scope: !28)
284 !56 = !DILocation(line: 21, scope: !28)
285 !57 = !DILocation(line: 25, scope: !31)
286 !58 = !DILocation(line: 26, scope: !31)
287 !59 = !DILocation(line: 29, scope: !33)
288 !60 = !DILocation(line: 30, scope: !33)
289 !61 = !DILocation(line: 31, scope: !33)
290 !62 = !DILocation(line: 32, scope: !31)
291 !63 = !DILocation(line: 34, scope: !8)
292 !64 = !DILocation(line: 35, scope: !35)
293 !65 = !DILocation(line: 36, scope: !35)
294 !66 = !DILocation(line: 37, scope: !35)
295 !67 = !DILocation(line: 39, scope: !8)
296 !68 = !DILocation(line: 40, scope: !8)