Dehao Chen | 23e2278 | 2015-11-19 19:53:05 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -add-discriminators -S | FileCheck %s |
| 2 | |
| 3 | ; Discriminator support for diamond-shaped CFG.: |
| 4 | ; #1 void bar(int); |
| 5 | ; #2 |
| 6 | ; #3 void foo(int i) { |
| 7 | ; #4 if (i > 10) |
| 8 | ; #5 bar(5); else bar(3); |
| 9 | ; #6 } |
| 10 | |
| 11 | ; bar(5): discriminator 0 |
| 12 | ; bar(3): discriminator 1 |
| 13 | |
| 14 | ; Function Attrs: uwtable |
| 15 | define void @_Z3fooi(i32 %i) #0 !dbg !4 { |
| 16 | %1 = alloca i32, align 4 |
| 17 | store i32 %i, i32* %1, align 4 |
| 18 | call void @llvm.dbg.declare(metadata i32* %1, metadata !11, metadata !12), !dbg !13 |
| 19 | %2 = load i32, i32* %1, align 4, !dbg !14 |
| 20 | %3 = icmp sgt i32 %2, 10, !dbg !16 |
| 21 | br i1 %3, label %4, label %5, !dbg !17 |
| 22 | |
| 23 | ; <label>:4 ; preds = %0 |
| 24 | call void @_Z3bari(i32 5), !dbg !18 |
| 25 | br label %6, !dbg !18 |
| 26 | |
| 27 | ; <label>:5 ; preds = %0 |
| 28 | call void @_Z3bari(i32 3), !dbg !19 |
| 29 | ; CHECK: call void @_Z3bari(i32 3), !dbg ![[ELSE:[0-9]+]] |
| 30 | br label %6 |
| 31 | |
| 32 | ; <label>:6 ; preds = %5, %4 |
| 33 | ret void, !dbg !20 |
| 34 | } |
| 35 | |
| 36 | ; Function Attrs: nounwind readnone |
| 37 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 38 | |
| 39 | declare void @_Z3bari(i32) #2 |
| 40 | |
| 41 | attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" } |
| 42 | attributes #1 = { nounwind readnone } |
| 43 | attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" } |
| 44 | |
| 45 | !llvm.dbg.cu = !{!0} |
| 46 | !llvm.module.flags = !{!8, !9} |
| 47 | !llvm.ident = !{!10} |
| 48 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame^] | 49 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 253273)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) |
Dehao Chen | 23e2278 | 2015-11-19 19:53:05 +0000 | [diff] [blame] | 50 | !1 = !DIFile(filename: "a.cc", directory: "/tmp") |
| 51 | !2 = !{} |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame^] | 52 | !4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) |
Dehao Chen | 23e2278 | 2015-11-19 19:53:05 +0000 | [diff] [blame] | 53 | !5 = !DISubroutineType(types: !6) |
| 54 | !6 = !{null, !7} |
| 55 | !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 56 | !8 = !{i32 2, !"Dwarf Version", i32 4} |
| 57 | !9 = !{i32 2, !"Debug Info Version", i32 3} |
| 58 | !10 = !{!"clang version 3.8.0 (trunk 253273)"} |
| 59 | !11 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 3, type: !7) |
| 60 | !12 = !DIExpression() |
| 61 | !13 = !DILocation(line: 3, column: 14, scope: !4) |
| 62 | !14 = !DILocation(line: 4, column: 7, scope: !15) |
| 63 | !15 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 7) |
| 64 | !16 = !DILocation(line: 4, column: 9, scope: !15) |
| 65 | !17 = !DILocation(line: 4, column: 7, scope: !4) |
| 66 | !18 = !DILocation(line: 5, column: 5, scope: !15) |
| 67 | !19 = !DILocation(line: 5, column: 18, scope: !15) |
| 68 | !20 = !DILocation(line: 6, column: 1, scope: !4) |
| 69 | |
| 70 | ; CHECK: ![[ELSE]] = !DILocation(line: 5, column: 18, scope: ![[ELSEBLOCK:[0-9]+]]) |
| 71 | ; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile({{.*}} discriminator: 1) |