bc3bcdf7b9687fae40f6767895cfbdf5c19ffe42
[oota-llvm.git] / test / Transforms / GCOVProfiling / return-block.ll
1 ; Inject metadata to set the .gcno file location
2 ; RUN: echo '!19 = !{!"%/T/return-block.ll", !0}' > %t1
3 ; RUN: cat %s %t1 > %t2
4
5 ; By default, the return block is last.
6 ; RUN: opt -insert-gcov-profiling -disable-output %t2
7 ; RUN: llvm-cov gcov -n -dump %T/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-LAST %s
8
9 ; But we can optionally emit it second, to match newer gcc versions.
10 ; RUN: opt -insert-gcov-profiling -gcov-exit-block-before-body -disable-output %t2
11 ; RUN: llvm-cov gcov -n -dump %T/return-block.gcno 2>&1 | FileCheck -check-prefix=CHECK -check-prefix=RETURN-SECOND %s
12
13 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux-gnu"
15
16 @A = common global i32 0, align 4
17
18 ; Function Attrs: nounwind uwtable
19 define void @test() #0 {
20 entry:
21   tail call void (...) @f() #2, !dbg !14
22   %0 = load i32, i32* @A, align 4, !dbg !15
23   %tobool = icmp eq i32 %0, 0, !dbg !15
24   br i1 %tobool, label %if.end, label %if.then, !dbg !15
25
26 if.then:                                          ; preds = %entry
27   tail call void (...) @g() #2, !dbg !16
28   br label %if.end, !dbg !16
29
30 if.end:                                           ; preds = %entry, %if.then
31   ret void, !dbg !18
32 }
33
34 declare void @f(...) #1
35
36 declare void @g(...) #1
37
38 attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
39 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
40 attributes #2 = { nounwind }
41
42 !llvm.gcov = !{!19}
43 !llvm.dbg.cu = !{!0}
44 !llvm.module.flags = !{!11, !12}
45 !llvm.ident = !{!13}
46
47 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 (trunk 223182)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !8, imports: !2)
48 !1 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
49 !2 = !{}
50 !3 = !{!4}
51 !4 = distinct !DISubprogram(name: "test", line: 5, isLocal: false, isDefinition: true, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !6, function: void ()* @test, variables: !2)
52 !5 = !DIFile(filename: ".../llvm/test/Transforms/GCOVProfiling/return-block.ll", directory: "")
53 !6 = !DISubroutineType(types: !7)
54 !7 = !{null}
55 !8 = !{!9}
56 !9 = !DIGlobalVariable(name: "A", line: 3, isLocal: false, isDefinition: true, scope: null, file: !5, type: !10, variable: i32* @A)
57 !10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
58 !11 = !{i32 2, !"Dwarf Version", i32 4}
59 !12 = !{i32 2, !"Debug Info Version", i32 3}
60 !13 = !{!"clang version 3.6.0 (trunk 223182)"}
61 !14 = !DILocation(line: 6, column: 3, scope: !4)
62 !15 = !DILocation(line: 7, column: 7, scope: !4)
63 !16 = !DILocation(line: 8, column: 5, scope: !17)
64 !17 = distinct !DILexicalBlock(line: 7, column: 7, file: !1, scope: !4)
65 !18 = !DILocation(line: 9, column: 1, scope: !4)
66
67 ; There should be no destination edges for the exit block.
68 ; CHECK: Block : 1 Counter : 0
69 ; RETURN-LAST:       Destination Edges
70 ; RETURN-SECOND-NOT: Destination Edges
71 ; CHECK: Block : 2 Counter : 0
72 ; CHECK: Block : 4 Counter : 0
73 ; RETURN-LAST-NOT: Destination Edges
74 ; RETURN-SECOND:   Destination Edges
75 ; CHECK-NOT: Block :