Skip to content

Commit fbc0067

Browse files
committed
coverage: Enable branch coverage in the branch coverage tests
1 parent 1f6a5ee commit fbc0067

12 files changed

+272
-116
lines changed

tests/coverage/branch_generics.cov-map

+18-9
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,52 @@
11
Function name: branch_generics::print_size::<()>
2-
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 01, 24, 05, 01, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
2+
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 2
66
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
77
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
8-
Number of file 0 mappings: 4
8+
Number of file 0 mappings: 5
99
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
10-
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
10+
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36)
11+
true = c1
12+
false = (c0 - c1)
13+
- Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6)
1114
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
1215
= (c0 - c1)
1316
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
1417
= (c1 + (c0 - c1))
1518

1619
Function name: branch_generics::print_size::<u32>
17-
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 01, 24, 05, 01, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
20+
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
1821
Number of files: 1
1922
- file 0 => global file 1
2023
Number of expressions: 2
2124
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
2225
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
23-
Number of file 0 mappings: 4
26+
Number of file 0 mappings: 5
2427
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
25-
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
28+
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36)
29+
true = c1
30+
false = (c0 - c1)
31+
- Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6)
2632
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
2733
= (c0 - c1)
2834
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
2935
= (c1 + (c0 - c1))
3036

3137
Function name: branch_generics::print_size::<u64>
32-
Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 01, 24, 05, 01, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
38+
Raw bytes (35): 0x[01, 01, 02, 01, 05, 05, 02, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 07, 03, 01, 00, 02]
3339
Number of files: 1
3440
- file 0 => global file 1
3541
Number of expressions: 2
3642
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
3743
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
38-
Number of file 0 mappings: 4
44+
Number of file 0 mappings: 5
3945
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
40-
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
46+
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36)
47+
true = c1
48+
false = (c0 - c1)
49+
- Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6)
4150
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
4251
= (c0 - c1)
4352
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)

tests/coverage/branch_generics.coverage

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
3-
LL| |
3+
LL| |//@ compile-flags: -Zcoverage-options=branch
44
LL| |//@ llvm-cov-flags: --show-branches=count
55
LL| |
66
LL| 3|fn print_size<T>() {
77
LL| 3| if std::mem::size_of::<T>() > 4 {
8+
------------------
9+
| Branch (LL:8): [True: 0, False: 1]
10+
| Branch (LL:8): [True: 0, False: 1]
11+
| Branch (LL:8): [True: 1, False: 0]
12+
------------------
813
LL| 1| println!("size > 4");
914
LL| 2| } else {
1015
LL| 2| println!("size <= 4");
@@ -14,6 +19,9 @@
1419
| branch_generics::print_size::<()>:
1520
| LL| 1|fn print_size<T>() {
1621
| LL| 1| if std::mem::size_of::<T>() > 4 {
22+
| ------------------
23+
| | Branch (LL:8): [True: 0, False: 1]
24+
| ------------------
1725
| LL| 0| println!("size > 4");
1826
| LL| 1| } else {
1927
| LL| 1| println!("size <= 4");
@@ -23,6 +31,9 @@
2331
| branch_generics::print_size::<u32>:
2432
| LL| 1|fn print_size<T>() {
2533
| LL| 1| if std::mem::size_of::<T>() > 4 {
34+
| ------------------
35+
| | Branch (LL:8): [True: 0, False: 1]
36+
| ------------------
2637
| LL| 0| println!("size > 4");
2738
| LL| 1| } else {
2839
| LL| 1| println!("size <= 4");
@@ -32,6 +43,9 @@
3243
| branch_generics::print_size::<u64>:
3344
| LL| 1|fn print_size<T>() {
3445
| LL| 1| if std::mem::size_of::<T>() > 4 {
46+
| ------------------
47+
| | Branch (LL:8): [True: 1, False: 0]
48+
| ------------------
3549
| LL| 1| println!("size > 4");
3650
| LL| 1| } else {
3751
| LL| 0| println!("size <= 4");

tests/coverage/branch_generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(coverage_attribute)]
22
//@ edition: 2021
3-
3+
//@ compile-flags: -Zcoverage-options=branch
44
//@ llvm-cov-flags: --show-branches=count
55

66
fn print_size<T>() {

tests/coverage/branch_guard.cov-map

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
Function name: branch_guard::branch_match_guard
2-
Raw bytes (67): 0x[01, 01, 04, 05, 09, 0b, 15, 0f, 11, 03, 0d, 0b, 01, 0c, 01, 01, 10, 1d, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 1d, 00, 14, 00, 19, 11, 00, 1d, 02, 0a, 03, 03, 0e, 02, 0a, 07, 04, 01, 00, 02]
2+
Raw bytes (85): 0x[01, 01, 06, 19, 0d, 05, 09, 0f, 15, 13, 11, 17, 0d, 05, 09, 0d, 01, 0c, 01, 01, 10, 1d, 03, 0b, 00, 0c, 15, 01, 14, 02, 0a, 0d, 03, 0e, 00, 0f, 19, 00, 14, 00, 19, 20, 0d, 02, 00, 14, 00, 1e, 0d, 00, 1d, 02, 0a, 11, 03, 0e, 00, 0f, 1d, 00, 14, 00, 19, 20, 11, 09, 00, 14, 00, 1e, 11, 00, 1d, 02, 0a, 17, 03, 0e, 02, 0a, 0b, 04, 01, 00, 02]
33
Number of files: 1
44
- file 0 => global file 1
5-
Number of expressions: 4
6-
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
7-
- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(5)
8-
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(4)
9-
- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(3)
10-
Number of file 0 mappings: 11
5+
Number of expressions: 6
6+
- expression 0 operands: lhs = Counter(6), rhs = Counter(3)
7+
- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
8+
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(5)
9+
- expression 3 operands: lhs = Expression(4, Add), rhs = Counter(4)
10+
- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3)
11+
- expression 5 operands: lhs = Counter(1), rhs = Counter(2)
12+
Number of file 0 mappings: 13
1113
- Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16)
1214
- Code(Counter(7)) at (prev + 3, 11) to (start + 0, 12)
1315
- Code(Counter(5)) at (prev + 1, 20) to (start + 2, 10)
1416
- Code(Counter(3)) at (prev + 3, 14) to (start + 0, 15)
1517
- Code(Counter(6)) at (prev + 0, 20) to (start + 0, 25)
18+
- Branch { true: Counter(3), false: Expression(0, Sub) } at (prev + 0, 20) to (start + 0, 30)
19+
true = c3
20+
false = (c6 - c3)
1621
- Code(Counter(3)) at (prev + 0, 29) to (start + 2, 10)
1722
- Code(Counter(4)) at (prev + 3, 14) to (start + 0, 15)
1823
- Code(Counter(7)) at (prev + 0, 20) to (start + 0, 25)
24+
- Branch { true: Counter(4), false: Counter(2) } at (prev + 0, 20) to (start + 0, 30)
25+
true = c4
26+
false = c2
1927
- Code(Counter(4)) at (prev + 0, 29) to (start + 2, 10)
20-
- Code(Expression(0, Add)) at (prev + 3, 14) to (start + 2, 10)
28+
- Code(Expression(5, Add)) at (prev + 3, 14) to (start + 2, 10)
2129
= (c1 + c2)
22-
- Code(Expression(1, Add)) at (prev + 4, 1) to (start + 0, 2)
30+
- Code(Expression(2, Add)) at (prev + 4, 1) to (start + 0, 2)
2331
= ((((c1 + c2) + c3) + c4) + c5)
2432

tests/coverage/branch_guard.coverage

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
LL| |#![feature(coverage_attribute)]
22
LL| |//@ edition: 2021
3-
LL| |
3+
LL| |//@ compile-flags: -Zcoverage-options=branch
44
LL| |//@ llvm-cov-flags: --show-branches=count
55
LL| |
66
LL| |macro_rules! no_merge {
@@ -18,9 +18,15 @@
1818
LL| 1| }
1919
LL| 3| Some(x) if x % 2 == 0 => {
2020
^2
21+
------------------
22+
| Branch (LL:20): [True: 2, False: 1]
23+
------------------
2124
LL| 2| println!("is nonzero and even");
2225
LL| 2| }
2326
LL| 1| Some(x) if x % 3 == 0 => {
27+
------------------
28+
| Branch (LL:20): [True: 1, False: 0]
29+
------------------
2430
LL| 1| println!("is nonzero and odd, but divisible by 3");
2531
LL| 1| }
2632
LL| 0| _ => {

tests/coverage/branch_guard.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(coverage_attribute)]
22
//@ edition: 2021
3-
3+
//@ compile-flags: -Zcoverage-options=branch
44
//@ llvm-cov-flags: --show-branches=count
55

66
macro_rules! no_merge {

0 commit comments

Comments
 (0)