Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -add-discriminators -S | FileCheck %s |
Xinliang David Li | 1eaecef | 2016-06-15 21:51:30 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -passes=add-discriminators -S | FileCheck %s |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 3 | |
| 4 | ; Discriminator support for code that is written in one line: |
| 5 | ; #1 int foo(int i) { |
| 6 | ; #2 if (i == 3 || i == 5) return 100; else return 99; |
| 7 | ; #3 } |
| 8 | |
| 9 | ; i == 3: discriminator 0 |
Dehao Chen | fb02f71 | 2017-02-10 21:09:07 +0000 | [diff] [blame] | 10 | ; i == 5: discriminator 2 |
| 11 | ; return 100: discriminator 4 |
| 12 | ; return 99: discriminator 6 |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 13 | |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 14 | define i32 @_Z3fooi(i32 %i) #0 !dbg !4 { |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 15 | %1 = alloca i32, align 4 |
| 16 | %2 = alloca i32, align 4 |
| 17 | store i32 %i, i32* %2, align 4, !tbaa !13 |
| 18 | call void @llvm.dbg.declare(metadata i32* %2, metadata !9, metadata !17), !dbg !18 |
| 19 | %3 = load i32, i32* %2, align 4, !dbg !19, !tbaa !13 |
| 20 | %4 = icmp eq i32 %3, 3, !dbg !21 |
| 21 | br i1 %4, label %8, label %5, !dbg !22 |
| 22 | |
| 23 | ; <label>:5 ; preds = %0 |
| 24 | %6 = load i32, i32* %2, align 4, !dbg !23, !tbaa !13 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 25 | ; CHECK: %6 = load i32, i32* %2, align 4, !dbg ![[THEN1:[0-9]+]],{{.*}} |
| 26 | |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 27 | %7 = icmp eq i32 %6, 5, !dbg !24 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 28 | ; CHECK: %7 = icmp eq i32 %6, 5, !dbg ![[THEN2:[0-9]+]] |
| 29 | |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 30 | br i1 %7, label %8, label %9, !dbg !25 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 31 | ; CHECK: br i1 %7, label %8, label %9, !dbg ![[THEN3:[0-9]+]] |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 32 | |
| 33 | ; <label>:8 ; preds = %5, %0 |
| 34 | store i32 100, i32* %1, align 4, !dbg !26 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 35 | ; CHECK: store i32 100, i32* %1, align 4, !dbg ![[ELSE:[0-9]+]] |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 36 | |
| 37 | br label %10, !dbg !26 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 38 | ; CHECK: br label %10, !dbg ![[ELSE]] |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 39 | |
| 40 | ; <label>:9 ; preds = %5 |
| 41 | store i32 99, i32* %1, align 4, !dbg !27 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 42 | ; CHECK: store i32 99, i32* %1, align 4, !dbg ![[COMBINE:[0-9]+]] |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 43 | |
| 44 | br label %10, !dbg !27 |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 45 | ; CHECK: br label %10, !dbg ![[COMBINE]] |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 46 | |
| 47 | ; <label>:10 ; preds = %9, %8 |
| 48 | %11 = load i32, i32* %1, align 4, !dbg !28 |
| 49 | ret i32 %11, !dbg !28 |
| 50 | } |
| 51 | |
| 52 | ; Function Attrs: nounwind readnone |
| 53 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 54 | |
| 55 | attributes #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" } |
| 56 | attributes #1 = { nounwind readnone } |
| 57 | |
Adrian Prantl | d1f52b67 | 2016-04-11 16:58:35 +0000 | [diff] [blame] | 58 | !llvm.dbg.cu = !{!0} |
Dehao Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 59 | !llvm.module.flags = !{!10, !11} |
| 60 | !llvm.ident = !{!12} |
| 61 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 62 | !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 Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 63 | !1 = !DIFile(filename: "a.cc", directory: "/usr/local/google/home/dehao/discr") |
| 64 | !2 = !{} |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 65 | !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 Chen | 49359bf | 2015-10-30 05:07:15 +0000 | [diff] [blame] | 66 | !5 = !DISubroutineType(types: !6) |
| 67 | !6 = !{!7, !7} |
| 68 | !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 69 | !8 = !{!9} |
| 70 | !9 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 1, type: !7) |
| 71 | !10 = !{i32 2, !"Dwarf Version", i32 4} |
| 72 | !11 = !{i32 2, !"Debug Info Version", i32 3} |
| 73 | !12 = !{!"clang version 3.8.0 (trunk 250915)"} |
| 74 | !13 = !{!14, !14, i64 0} |
| 75 | !14 = !{!"int", !15, i64 0} |
| 76 | !15 = !{!"omnipotent char", !16, i64 0} |
| 77 | !16 = !{!"Simple C/C++ TBAA"} |
| 78 | !17 = !DIExpression() |
| 79 | !18 = !DILocation(line: 1, column: 13, scope: !4) |
| 80 | !19 = !DILocation(line: 2, column: 7, scope: !20) |
| 81 | !20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 2, column: 7) |
| 82 | !21 = !DILocation(line: 2, column: 9, scope: !20) |
| 83 | !22 = !DILocation(line: 2, column: 14, scope: !20) |
| 84 | !23 = !DILocation(line: 2, column: 17, scope: !20) |
| 85 | !24 = !DILocation(line: 2, column: 19, scope: !20) |
| 86 | !25 = !DILocation(line: 2, column: 7, scope: !4) |
| 87 | !26 = !DILocation(line: 2, column: 25, scope: !20) |
| 88 | !27 = !DILocation(line: 2, column: 42, scope: !20) |
| 89 | !28 = !DILocation(line: 3, column: 1, scope: !4) |
| 90 | |
Adrian Prantl | 28d2d28 | 2016-10-24 18:23:51 +0000 | [diff] [blame] | 91 | ; CHECK: ![[F:.*]] = distinct !DISubprogram(name: "foo", |
| 92 | ; CHECK: ![[IF:.*]] = distinct !DILexicalBlock(scope: ![[F]],{{.*}}line: 2, column: 7) |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 93 | ; CHECK: ![[THEN1]] = !DILocation(line: 2, column: 17, scope: ![[THENBLOCK:[0-9]+]]) |
Dehao Chen | fb02f71 | 2017-02-10 21:09:07 +0000 | [diff] [blame] | 94 | ; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile(scope: ![[IF]],{{.*}} discriminator: 2) |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 95 | ; CHECK: ![[THEN2]] = !DILocation(line: 2, column: 19, scope: ![[THENBLOCK]]) |
Adrian Prantl | 28d2d28 | 2016-10-24 18:23:51 +0000 | [diff] [blame] | 96 | ; CHECK: ![[THEN3]] = !DILocation(line: 2, column: 7, scope: ![[BRBLOCK:[0-9]+]]) |
Dehao Chen | fb02f71 | 2017-02-10 21:09:07 +0000 | [diff] [blame] | 97 | ; CHECK: ![[BRBLOCK]] = !DILexicalBlockFile(scope: ![[F]],{{.*}} discriminator: 2) |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 98 | ; CHECK: ![[ELSE]] = !DILocation(line: 2, column: 25, scope: ![[ELSEBLOCK:[0-9]+]]) |
Dehao Chen | fb02f71 | 2017-02-10 21:09:07 +0000 | [diff] [blame] | 99 | ; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile(scope: ![[IF]],{{.*}} discriminator: 4) |
Dehao Chen | f50c67c | 2016-05-05 20:47:53 +0000 | [diff] [blame] | 100 | ; CHECK: ![[COMBINE]] = !DILocation(line: 2, column: 42, scope: ![[COMBINEBLOCK:[0-9]+]]) |
Dehao Chen | fb02f71 | 2017-02-10 21:09:07 +0000 | [diff] [blame] | 101 | ; CHECK: ![[COMBINEBLOCK]] = !DILexicalBlockFile(scope: ![[IF]],{{.*}} discriminator: 6) |