blob: f07fa09ce0e72d39d274ee27c56ff735ce5229e0 [file] [log] [blame]
Dehao Chen49359bf2015-10-30 05:07:15 +00001; RUN: opt < %s -add-discriminators -S | FileCheck %s
2
3; Discriminator support for code that is written in one line:
4; #1 int foo(int i) {
5; #2 if (i == 3 || i == 5) return 100; else return 99;
6; #3 }
7
8; i == 3: discriminator 0
Dehao Chen23e22782015-11-19 19:53:05 +00009; i == 5: discriminator 1
10; return 100: discriminator 2
Dehao Chen49359bf2015-10-30 05:07:15 +000011; return 99: discriminator 3
12
Peter Collingbourned4bff302015-11-05 22:03:56 +000013define i32 @_Z3fooi(i32 %i) #0 !dbg !4 {
Dehao Chen49359bf2015-10-30 05:07:15 +000014 %1 = alloca i32, align 4
15 %2 = alloca i32, align 4
16 store i32 %i, i32* %2, align 4, !tbaa !13
17 call void @llvm.dbg.declare(metadata i32* %2, metadata !9, metadata !17), !dbg !18
18 %3 = load i32, i32* %2, align 4, !dbg !19, !tbaa !13
19 %4 = icmp eq i32 %3, 3, !dbg !21
20 br i1 %4, label %8, label %5, !dbg !22
21
22; <label>:5 ; preds = %0
23 %6 = load i32, i32* %2, align 4, !dbg !23, !tbaa !13
Dehao Chenf50c67c2016-05-05 20:47:53 +000024; CHECK: %6 = load i32, i32* %2, align 4, !dbg ![[THEN1:[0-9]+]],{{.*}}
25
Dehao Chen49359bf2015-10-30 05:07:15 +000026 %7 = icmp eq i32 %6, 5, !dbg !24
Dehao Chenf50c67c2016-05-05 20:47:53 +000027; CHECK: %7 = icmp eq i32 %6, 5, !dbg ![[THEN2:[0-9]+]]
28
Dehao Chen49359bf2015-10-30 05:07:15 +000029 br i1 %7, label %8, label %9, !dbg !25
Dehao Chenf50c67c2016-05-05 20:47:53 +000030; CHECK: br i1 %7, label %8, label %9, !dbg ![[THEN3:[0-9]+]]
Dehao Chen49359bf2015-10-30 05:07:15 +000031
32; <label>:8 ; preds = %5, %0
33 store i32 100, i32* %1, align 4, !dbg !26
Dehao Chenf50c67c2016-05-05 20:47:53 +000034; CHECK: store i32 100, i32* %1, align 4, !dbg ![[ELSE:[0-9]+]]
Dehao Chen49359bf2015-10-30 05:07:15 +000035
36 br label %10, !dbg !26
Dehao Chenf50c67c2016-05-05 20:47:53 +000037; CHECK: br label %10, !dbg ![[ELSE]]
Dehao Chen49359bf2015-10-30 05:07:15 +000038
39; <label>:9 ; preds = %5
40 store i32 99, i32* %1, align 4, !dbg !27
Dehao Chenf50c67c2016-05-05 20:47:53 +000041; CHECK: store i32 99, i32* %1, align 4, !dbg ![[COMBINE:[0-9]+]]
Dehao Chen49359bf2015-10-30 05:07:15 +000042
43 br label %10, !dbg !27
Dehao Chenf50c67c2016-05-05 20:47:53 +000044; CHECK: br label %10, !dbg ![[COMBINE]]
Dehao Chen49359bf2015-10-30 05:07:15 +000045
46; <label>:10 ; preds = %9, %8
47 %11 = load i32, i32* %1, align 4, !dbg !28
48 ret i32 %11, !dbg !28
49}
50
51; Function Attrs: nounwind readnone
52declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
53
54attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
55attributes #1 = { nounwind readnone }
56
Adrian Prantld1f52b672016-04-11 16:58:35 +000057!llvm.dbg.cu = !{!0}
Dehao Chen49359bf2015-10-30 05:07:15 +000058!llvm.module.flags = !{!10, !11}
59!llvm.ident = !{!12}
60
Adrian Prantl75819ae2016-04-15 15:57:41 +000061!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 250915)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
Dehao Chen49359bf2015-10-30 05:07:15 +000062!1 = !DIFile(filename: "a.cc", directory: "/usr/local/google/home/dehao/discr")
63!2 = !{}
Adrian Prantl75819ae2016-04-15 15:57:41 +000064!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !8)
Dehao Chen49359bf2015-10-30 05:07:15 +000065!5 = !DISubroutineType(types: !6)
66!6 = !{!7, !7}
67!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
68!8 = !{!9}
69!9 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 1, type: !7)
70!10 = !{i32 2, !"Dwarf Version", i32 4}
71!11 = !{i32 2, !"Debug Info Version", i32 3}
72!12 = !{!"clang version 3.8.0 (trunk 250915)"}
73!13 = !{!14, !14, i64 0}
74!14 = !{!"int", !15, i64 0}
75!15 = !{!"omnipotent char", !16, i64 0}
76!16 = !{!"Simple C/C++ TBAA"}
77!17 = !DIExpression()
78!18 = !DILocation(line: 1, column: 13, scope: !4)
79!19 = !DILocation(line: 2, column: 7, scope: !20)
80!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 7)
81!21 = !DILocation(line: 2, column: 9, scope: !20)
82!22 = !DILocation(line: 2, column: 14, scope: !20)
83!23 = !DILocation(line: 2, column: 17, scope: !20)
84!24 = !DILocation(line: 2, column: 19, scope: !20)
85!25 = !DILocation(line: 2, column: 7, scope: !4)
86!26 = !DILocation(line: 2, column: 25, scope: !20)
87!27 = !DILocation(line: 2, column: 42, scope: !20)
88!28 = !DILocation(line: 3, column: 1, scope: !4)
89
Dehao Chenf50c67c2016-05-05 20:47:53 +000090; CHECK: ![[THEN1]] = !DILocation(line: 2, column: 17, scope: ![[THENBLOCK:[0-9]+]])
Dehao Chen23e22782015-11-19 19:53:05 +000091; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 1)
Dehao Chenf50c67c2016-05-05 20:47:53 +000092; CHECK: ![[THEN2]] = !DILocation(line: 2, column: 19, scope: ![[THENBLOCK]])
93; CHECK: ![[THEN3]] = !DILocation(line: 2, column: 7, scope: ![[THENBLOCK]])
94; CHECK: ![[ELSE]] = !DILocation(line: 2, column: 25, scope: ![[ELSEBLOCK:[0-9]+]])
Dehao Chen23e22782015-11-19 19:53:05 +000095; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 2)
Dehao Chenf50c67c2016-05-05 20:47:53 +000096; CHECK: ![[COMBINE]] = !DILocation(line: 2, column: 42, scope: ![[COMBINEBLOCK:[0-9]+]])
97; CHECK: ![[COMBINEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 3)