Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / tools / llvm-cov / branch-templates.cpp
blob4797428f8835aeead155b022090c883706ff546b
1 // RUN: llvm-profdata merge %S/Inputs/branch-templates.proftext -o %t.profdata
2 // RUN: llvm-cov show --show-expansions --show-branches=count %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
3 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -show-functions -path-equivalence=/tmp,%S %s | FileCheck %s -check-prefix=REPORT
4 // RUN: llvm-cov report --show-branch-summary %S/Inputs/branch-templates.o32l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s -check-prefix=REPORTFILE
6 #include <stdio.h>
7 template<typename T>
8 void unused(T x) {
9 return;
12 template<typename T>
13 int func(T x) {
14 if(x) // CHECK: | Branch ([[@LINE]]:6): [True: 0, False: 1]
15 return 0; // CHECK: | Branch ([[@LINE-1]]:6): [True: 1, False: 0]
16 else // CHECK: | Branch ([[@LINE-2]]:6): [True: 0, False: 1]
17 return 1;
18 int j = 1;
21 // CHECK-LABEL: _Z4funcIiEiT_:
22 // CHECK: | | Branch ([[@LINE-8]]:6): [True: 0, False: 1]
23 // CHECK-LABEL: _Z4funcIbEiT_:
24 // CHECK: | | Branch ([[@LINE-10]]:6): [True: 1, False: 0]
25 // CHECK-LABEL: _Z4funcIfEiT_:
26 // CHECK: | | Branch ([[@LINE-12]]:6): [True: 0, False: 1]
28 extern "C" { extern void __llvm_profile_write_file(void); }
29 int main() {
30 if (func<int>(0)) // CHECK: | Branch ([[@LINE]]:7): [True: 1, False: 0]
31 printf("case1\n");
32 if (func<bool>(true)) // CHECK: | Branch ([[@LINE]]:7): [True: 0, False: 1]
33 printf("case2\n");
34 if (func<float>(0.0)) // CHECK: | Branch ([[@LINE]]:7): [True: 1, False: 0]
35 printf("case3\n");
36 __llvm_profile_write_file();
37 return 0;
40 // REPORT: Name Regions Miss Cover Lines Miss Cover Branches Miss Cover
41 // REPORT-NEXT: ---
42 // REPORT-NEXT: main 7 1 85.71% 10 1 90.00% 6 3 50.00%
43 // REPORT-NEXT: _Z4funcIiEiT_ 5 2 60.00% 7 3 57.14% 2 1 50.00%
44 // REPORT-NEXT: _Z4funcIbEiT_ 5 2 60.00% 7 4 42.86% 2 1 50.00%
45 // REPORT-NEXT: _Z4funcIfEiT_ 5 2 60.00% 7 3 57.14% 2 1 50.00%
46 // REPORT-NEXT: ---
47 // REPORT-NEXT: TOTAL 22 7 68.18% 31 11 64.52% 12 6 50.00%
49 // Make sure the covered branch tally for the function instantiation group is
50 // merged to reflect maximum branch coverage of a single instantiation, just
51 // like what is done for lines and regions. Also, the total branch tally
52 // summary for an instantiation group should agree with the total number of
53 // branches in the definition (In this case, 2 and 6 for func<>() and main(),
54 // respectively). This is returned by: FunctionCoverageSummary::get(const
55 // InstantiationGroup &Group, ...)
57 // REPORTFILE: Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
58 // REPORTFILE-NEXT: ---
59 // REPORTFILE-NEXT: branch-templates.cpp 12 3 75.00% 2 0 100.00% 17 4 76.47% 8 4 50.00%
60 // REPORTFILE-NEXT: ---
61 // REPORTFILE-NEXT: TOTAL 12 3 75.00% 2 0 100.00% 17 4 76.47% 8 4 50.00%