coverage: Add branch coverage tests (with branch coverage disabled)
This commit is contained in:
parent
762d3170f6
commit
89fab06a77
45
tests/coverage/branch_generics.cov-map
Normal file
45
tests/coverage/branch_generics.cov-map
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
Function name: branch_generics::print_size::<()>
|
||||||
|
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]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
|
||||||
|
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
||||||
|
Function name: branch_generics::print_size::<u32>
|
||||||
|
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]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
|
||||||
|
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
||||||
|
Function name: branch_generics::print_size::<u64>
|
||||||
|
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]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(0), rhs = Counter(1)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 4
|
||||||
|
- Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36)
|
||||||
|
- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6)
|
||||||
|
= (c0 - c1)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= (c1 + (c0 - c1))
|
||||||
|
|
48
tests/coverage/branch_generics.coverage
Normal file
48
tests/coverage/branch_generics.coverage
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |//@ edition: 2021
|
||||||
|
LL| |
|
||||||
|
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn print_size<T>() {
|
||||||
|
LL| 3| if std::mem::size_of::<T>() > 4 {
|
||||||
|
LL| 1| println!("size > 4");
|
||||||
|
LL| 2| } else {
|
||||||
|
LL| 2| println!("size <= 4");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 3|}
|
||||||
|
------------------
|
||||||
|
| branch_generics::print_size::<()>:
|
||||||
|
| LL| 1|fn print_size<T>() {
|
||||||
|
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||||
|
| LL| 0| println!("size > 4");
|
||||||
|
| LL| 1| } else {
|
||||||
|
| LL| 1| println!("size <= 4");
|
||||||
|
| LL| 1| }
|
||||||
|
| LL| 1|}
|
||||||
|
------------------
|
||||||
|
| branch_generics::print_size::<u32>:
|
||||||
|
| LL| 1|fn print_size<T>() {
|
||||||
|
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||||
|
| LL| 0| println!("size > 4");
|
||||||
|
| LL| 1| } else {
|
||||||
|
| LL| 1| println!("size <= 4");
|
||||||
|
| LL| 1| }
|
||||||
|
| LL| 1|}
|
||||||
|
------------------
|
||||||
|
| branch_generics::print_size::<u64>:
|
||||||
|
| LL| 1|fn print_size<T>() {
|
||||||
|
| LL| 1| if std::mem::size_of::<T>() > 4 {
|
||||||
|
| LL| 1| println!("size > 4");
|
||||||
|
| LL| 1| } else {
|
||||||
|
| LL| 0| println!("size <= 4");
|
||||||
|
| LL| 0| }
|
||||||
|
| LL| 1|}
|
||||||
|
------------------
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | print_size::<()>();
|
||||||
|
LL| | print_size::<u32>();
|
||||||
|
LL| | print_size::<u64>();
|
||||||
|
LL| |}
|
||||||
|
|
19
tests/coverage/branch_generics.rs
Normal file
19
tests/coverage/branch_generics.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
//@ edition: 2021
|
||||||
|
|
||||||
|
//@ llvm-cov-flags: --show-branches=count
|
||||||
|
|
||||||
|
fn print_size<T>() {
|
||||||
|
if std::mem::size_of::<T>() > 4 {
|
||||||
|
println!("size > 4");
|
||||||
|
} else {
|
||||||
|
println!("size <= 4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
print_size::<()>();
|
||||||
|
print_size::<u32>();
|
||||||
|
print_size::<u64>();
|
||||||
|
}
|
24
tests/coverage/branch_guard.cov-map
Normal file
24
tests/coverage/branch_guard.cov-map
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Function name: branch_guard::branch_match_guard
|
||||||
|
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]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 4
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Expression(2, Add), rhs = Counter(5)
|
||||||
|
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(4)
|
||||||
|
- expression 3 operands: lhs = Expression(0, Add), rhs = Counter(3)
|
||||||
|
Number of file 0 mappings: 11
|
||||||
|
- Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(7)) at (prev + 3, 11) to (start + 0, 12)
|
||||||
|
- Code(Counter(5)) at (prev + 1, 20) to (start + 2, 10)
|
||||||
|
- Code(Counter(3)) at (prev + 3, 14) to (start + 0, 15)
|
||||||
|
- Code(Counter(6)) at (prev + 0, 20) to (start + 0, 25)
|
||||||
|
- Code(Counter(3)) at (prev + 0, 29) to (start + 2, 10)
|
||||||
|
- Code(Counter(4)) at (prev + 3, 14) to (start + 0, 15)
|
||||||
|
- Code(Counter(7)) at (prev + 0, 20) to (start + 0, 25)
|
||||||
|
- Code(Counter(4)) at (prev + 0, 29) to (start + 2, 10)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 3, 14) to (start + 2, 10)
|
||||||
|
= (c1 + c2)
|
||||||
|
- Code(Expression(1, Add)) at (prev + 4, 1) to (start + 0, 2)
|
||||||
|
= ((((c1 + c2) + c3) + c4) + c5)
|
||||||
|
|
39
tests/coverage/branch_guard.coverage
Normal file
39
tests/coverage/branch_guard.coverage
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |//@ edition: 2021
|
||||||
|
LL| |
|
||||||
|
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||||
|
LL| |
|
||||||
|
LL| |macro_rules! no_merge {
|
||||||
|
LL| | () => {
|
||||||
|
LL| | for _ in 0..1 {}
|
||||||
|
LL| | };
|
||||||
|
LL| |}
|
||||||
|
LL| |
|
||||||
|
LL| 4|fn branch_match_guard(x: Option<u32>) {
|
||||||
|
LL| 4| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 1| match x {
|
||||||
|
LL| 1| Some(0) => {
|
||||||
|
LL| 1| println!("zero");
|
||||||
|
LL| 1| }
|
||||||
|
LL| 3| Some(x) if x % 2 == 0 => {
|
||||||
|
^2
|
||||||
|
LL| 2| println!("is nonzero and even");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 1| Some(x) if x % 3 == 0 => {
|
||||||
|
LL| 1| println!("is nonzero and odd, but divisible by 3");
|
||||||
|
LL| 1| }
|
||||||
|
LL| 0| _ => {
|
||||||
|
LL| 0| println!("something else");
|
||||||
|
LL| 0| }
|
||||||
|
LL| | }
|
||||||
|
LL| 4|}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | branch_match_guard(Some(0));
|
||||||
|
LL| | branch_match_guard(Some(2));
|
||||||
|
LL| | branch_match_guard(Some(6));
|
||||||
|
LL| | branch_match_guard(Some(3));
|
||||||
|
LL| |}
|
||||||
|
|
37
tests/coverage/branch_guard.rs
Normal file
37
tests/coverage/branch_guard.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
//@ edition: 2021
|
||||||
|
|
||||||
|
//@ llvm-cov-flags: --show-branches=count
|
||||||
|
|
||||||
|
macro_rules! no_merge {
|
||||||
|
() => {
|
||||||
|
for _ in 0..1 {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branch_match_guard(x: Option<u32>) {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
match x {
|
||||||
|
Some(0) => {
|
||||||
|
println!("zero");
|
||||||
|
}
|
||||||
|
Some(x) if x % 2 == 0 => {
|
||||||
|
println!("is nonzero and even");
|
||||||
|
}
|
||||||
|
Some(x) if x % 3 == 0 => {
|
||||||
|
println!("is nonzero and odd, but divisible by 3");
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("something else");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
branch_match_guard(Some(0));
|
||||||
|
branch_match_guard(Some(2));
|
||||||
|
branch_match_guard(Some(6));
|
||||||
|
branch_match_guard(Some(3));
|
||||||
|
}
|
136
tests/coverage/branch_if.cov-map
Normal file
136
tests/coverage/branch_if.cov-map
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
Function name: branch_if::branch_and
|
||||||
|
Raw bytes (40): 0x[01, 01, 03, 06, 0d, 05, 09, 11, 03, 06, 01, 2b, 01, 01, 10, 05, 03, 08, 00, 09, 09, 00, 0d, 00, 0e, 11, 00, 0f, 02, 06, 03, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 3
|
||||||
|
- expression 0 operands: lhs = Expression(1, Sub), rhs = Counter(3)
|
||||||
|
- expression 1 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 2 operands: lhs = Counter(4), rhs = Expression(0, Add)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 43, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9)
|
||||||
|
- Code(Counter(2)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
- Code(Counter(4)) at (prev + 0, 15) to (start + 2, 6)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 2, 12) to (start + 2, 6)
|
||||||
|
= ((c1 - c2) + c3)
|
||||||
|
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= (c4 + ((c1 - c2) + c3))
|
||||||
|
|
||||||
|
Function name: branch_if::branch_not
|
||||||
|
Raw bytes (132): 0x[01, 01, 1d, 05, 09, 09, 02, 73, 0d, 09, 02, 0d, 6e, 73, 0d, 09, 02, 6b, 11, 0d, 6e, 73, 0d, 09, 02, 11, 66, 6b, 11, 0d, 6e, 73, 0d, 09, 02, 63, 15, 11, 66, 6b, 11, 0d, 6e, 73, 0d, 09, 02, 15, 5e, 63, 15, 11, 66, 6b, 11, 0d, 6e, 73, 0d, 09, 02, 0e, 01, 0c, 01, 01, 10, 05, 03, 08, 00, 09, 09, 01, 09, 00, 11, 02, 01, 06, 00, 07, 73, 01, 08, 00, 0a, 6e, 00, 0b, 02, 06, 0d, 02, 06, 00, 07, 6b, 01, 08, 00, 0b, 11, 00, 0c, 02, 06, 66, 02, 06, 00, 07, 63, 01, 08, 00, 0c, 5e, 00, 0d, 02, 06, 15, 02, 06, 00, 07, 5b, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 29
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 2 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 4 operands: lhs = Counter(3), rhs = Expression(27, Sub)
|
||||||
|
- expression 5 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 6 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 7 operands: lhs = Expression(26, Add), rhs = Counter(4)
|
||||||
|
- expression 8 operands: lhs = Counter(3), rhs = Expression(27, Sub)
|
||||||
|
- expression 9 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 10 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 11 operands: lhs = Counter(4), rhs = Expression(25, Sub)
|
||||||
|
- expression 12 operands: lhs = Expression(26, Add), rhs = Counter(4)
|
||||||
|
- expression 13 operands: lhs = Counter(3), rhs = Expression(27, Sub)
|
||||||
|
- expression 14 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 15 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 16 operands: lhs = Expression(24, Add), rhs = Counter(5)
|
||||||
|
- expression 17 operands: lhs = Counter(4), rhs = Expression(25, Sub)
|
||||||
|
- expression 18 operands: lhs = Expression(26, Add), rhs = Counter(4)
|
||||||
|
- expression 19 operands: lhs = Counter(3), rhs = Expression(27, Sub)
|
||||||
|
- expression 20 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 21 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 22 operands: lhs = Counter(5), rhs = Expression(23, Sub)
|
||||||
|
- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(5)
|
||||||
|
- expression 24 operands: lhs = Counter(4), rhs = Expression(25, Sub)
|
||||||
|
- expression 25 operands: lhs = Expression(26, Add), rhs = Counter(4)
|
||||||
|
- expression 26 operands: lhs = Counter(3), rhs = Expression(27, Sub)
|
||||||
|
- expression 27 operands: lhs = Expression(28, Add), rhs = Counter(3)
|
||||||
|
- expression 28 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 14
|
||||||
|
- Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9)
|
||||||
|
- Code(Counter(2)) at (prev + 1, 9) to (start + 0, 17)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 0, 7)
|
||||||
|
= (c1 - c2)
|
||||||
|
- Code(Expression(28, Add)) at (prev + 1, 8) to (start + 0, 10)
|
||||||
|
= (c2 + (c1 - c2))
|
||||||
|
- Code(Expression(27, Sub)) at (prev + 0, 11) to (start + 2, 6)
|
||||||
|
= ((c2 + (c1 - c2)) - c3)
|
||||||
|
- Code(Counter(3)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
- Code(Expression(26, Add)) at (prev + 1, 8) to (start + 0, 11)
|
||||||
|
= (c3 + ((c2 + (c1 - c2)) - c3))
|
||||||
|
- Code(Counter(4)) at (prev + 0, 12) to (start + 2, 6)
|
||||||
|
- Code(Expression(25, Sub)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
= ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)
|
||||||
|
- Code(Expression(24, Add)) at (prev + 1, 8) to (start + 0, 12)
|
||||||
|
= (c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4))
|
||||||
|
- Code(Expression(23, Sub)) at (prev + 0, 13) to (start + 2, 6)
|
||||||
|
= ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5)
|
||||||
|
- Code(Counter(5)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
- Code(Expression(22, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
= (c5 + ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5))
|
||||||
|
|
||||||
|
Function name: branch_if::branch_not_as
|
||||||
|
Raw bytes (91): 0x[01, 01, 10, 05, 09, 09, 02, 3f, 0d, 09, 02, 0d, 3a, 3f, 0d, 09, 02, 37, 11, 0d, 3a, 3f, 0d, 09, 02, 11, 32, 37, 11, 0d, 3a, 3f, 0d, 09, 02, 0b, 01, 1d, 01, 01, 10, 05, 03, 08, 00, 14, 02, 00, 15, 02, 06, 09, 02, 06, 00, 07, 3f, 01, 08, 00, 15, 0d, 00, 16, 02, 06, 3a, 02, 06, 00, 07, 37, 01, 08, 00, 16, 32, 00, 17, 02, 06, 11, 02, 06, 00, 07, 2f, 01, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 16
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 2 operands: lhs = Expression(15, Add), rhs = Counter(3)
|
||||||
|
- expression 3 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 4 operands: lhs = Counter(3), rhs = Expression(14, Sub)
|
||||||
|
- expression 5 operands: lhs = Expression(15, Add), rhs = Counter(3)
|
||||||
|
- expression 6 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 7 operands: lhs = Expression(13, Add), rhs = Counter(4)
|
||||||
|
- expression 8 operands: lhs = Counter(3), rhs = Expression(14, Sub)
|
||||||
|
- expression 9 operands: lhs = Expression(15, Add), rhs = Counter(3)
|
||||||
|
- expression 10 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
- expression 11 operands: lhs = Counter(4), rhs = Expression(12, Sub)
|
||||||
|
- expression 12 operands: lhs = Expression(13, Add), rhs = Counter(4)
|
||||||
|
- expression 13 operands: lhs = Counter(3), rhs = Expression(14, Sub)
|
||||||
|
- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(3)
|
||||||
|
- expression 15 operands: lhs = Counter(2), rhs = Expression(0, Sub)
|
||||||
|
Number of file 0 mappings: 11
|
||||||
|
- Code(Counter(0)) at (prev + 29, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 8) to (start + 0, 20)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 0, 21) to (start + 2, 6)
|
||||||
|
= (c1 - c2)
|
||||||
|
- Code(Counter(2)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
- Code(Expression(15, Add)) at (prev + 1, 8) to (start + 0, 21)
|
||||||
|
= (c2 + (c1 - c2))
|
||||||
|
- Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6)
|
||||||
|
- Code(Expression(14, Sub)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
= ((c2 + (c1 - c2)) - c3)
|
||||||
|
- Code(Expression(13, Add)) at (prev + 1, 8) to (start + 0, 22)
|
||||||
|
= (c3 + ((c2 + (c1 - c2)) - c3))
|
||||||
|
- Code(Expression(12, Sub)) at (prev + 0, 23) to (start + 2, 6)
|
||||||
|
= ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)
|
||||||
|
- Code(Counter(4)) at (prev + 2, 6) to (start + 0, 7)
|
||||||
|
- Code(Expression(11, Add)) at (prev + 1, 1) to (start + 0, 2)
|
||||||
|
= (c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4))
|
||||||
|
|
||||||
|
Function name: branch_if::branch_or
|
||||||
|
Raw bytes (42): 0x[01, 01, 04, 05, 09, 09, 0d, 0f, 11, 09, 0d, 06, 01, 35, 01, 01, 10, 05, 03, 08, 00, 09, 02, 00, 0d, 00, 0e, 0f, 00, 0f, 02, 06, 11, 02, 0c, 02, 06, 0b, 03, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 4
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Counter(3)
|
||||||
|
- expression 2 operands: lhs = Expression(3, Add), rhs = Counter(4)
|
||||||
|
- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 53, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9)
|
||||||
|
- Code(Expression(0, Sub)) at (prev + 0, 13) to (start + 0, 14)
|
||||||
|
= (c1 - c2)
|
||||||
|
- Code(Expression(3, Add)) at (prev + 0, 15) to (start + 2, 6)
|
||||||
|
= (c2 + c3)
|
||||||
|
- Code(Counter(4)) at (prev + 2, 12) to (start + 2, 6)
|
||||||
|
- Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= ((c2 + c3) + c4)
|
||||||
|
|
86
tests/coverage/branch_if.coverage
Normal file
86
tests/coverage/branch_if.coverage
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |//@ edition: 2021
|
||||||
|
LL| |
|
||||||
|
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||||
|
LL| |
|
||||||
|
LL| |macro_rules! no_merge {
|
||||||
|
LL| | () => {
|
||||||
|
LL| | for _ in 0..1 {}
|
||||||
|
LL| | };
|
||||||
|
LL| |}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn branch_not(a: bool) {
|
||||||
|
LL| 3| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 3| if a {
|
||||||
|
LL| 2| say("a")
|
||||||
|
LL| 1| }
|
||||||
|
LL| 3| if !a {
|
||||||
|
LL| 1| say("not a");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 3| if !!a {
|
||||||
|
LL| 2| say("not not a");
|
||||||
|
LL| 2| }
|
||||||
|
^1
|
||||||
|
LL| 3| if !!!a {
|
||||||
|
LL| 1| say("not not not a");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| 3|fn branch_not_as(a: bool) {
|
||||||
|
LL| 3| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 3| if !(a as bool) {
|
||||||
|
LL| 1| say("not (a as bool)");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 3| if !!(a as bool) {
|
||||||
|
LL| 2| say("not not (a as bool)");
|
||||||
|
LL| 2| }
|
||||||
|
^1
|
||||||
|
LL| 3| if !!!(a as bool) {
|
||||||
|
LL| 1| say("not not (a as bool)");
|
||||||
|
LL| 2| }
|
||||||
|
LL| 3|}
|
||||||
|
LL| |
|
||||||
|
LL| 15|fn branch_and(a: bool, b: bool) {
|
||||||
|
LL| 15| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 15| if a && b {
|
||||||
|
^12
|
||||||
|
LL| 8| say("both");
|
||||||
|
LL| 8| } else {
|
||||||
|
LL| 7| say("not both");
|
||||||
|
LL| 7| }
|
||||||
|
LL| 15|}
|
||||||
|
LL| |
|
||||||
|
LL| 15|fn branch_or(a: bool, b: bool) {
|
||||||
|
LL| 15| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 15| if a || b {
|
||||||
|
^3
|
||||||
|
LL| 14| say("either");
|
||||||
|
LL| 14| } else {
|
||||||
|
LL| 1| say("neither");
|
||||||
|
LL| 1| }
|
||||||
|
LL| 15|}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn say(message: &str) {
|
||||||
|
LL| | core::hint::black_box(message);
|
||||||
|
LL| |}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | for a in [false, true, true] {
|
||||||
|
LL| | branch_not(a);
|
||||||
|
LL| | branch_not_as(a);
|
||||||
|
LL| | }
|
||||||
|
LL| |
|
||||||
|
LL| | for a in [false, true, true, true, true] {
|
||||||
|
LL| | for b in [false, true, true] {
|
||||||
|
LL| | branch_and(a, b);
|
||||||
|
LL| | branch_or(a, b);
|
||||||
|
LL| | }
|
||||||
|
LL| | }
|
||||||
|
LL| |}
|
||||||
|
|
81
tests/coverage/branch_if.rs
Normal file
81
tests/coverage/branch_if.rs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
//@ edition: 2021
|
||||||
|
|
||||||
|
//@ llvm-cov-flags: --show-branches=count
|
||||||
|
|
||||||
|
macro_rules! no_merge {
|
||||||
|
() => {
|
||||||
|
for _ in 0..1 {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branch_not(a: bool) {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
if a {
|
||||||
|
say("a")
|
||||||
|
}
|
||||||
|
if !a {
|
||||||
|
say("not a");
|
||||||
|
}
|
||||||
|
if !!a {
|
||||||
|
say("not not a");
|
||||||
|
}
|
||||||
|
if !!!a {
|
||||||
|
say("not not not a");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branch_not_as(a: bool) {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
if !(a as bool) {
|
||||||
|
say("not (a as bool)");
|
||||||
|
}
|
||||||
|
if !!(a as bool) {
|
||||||
|
say("not not (a as bool)");
|
||||||
|
}
|
||||||
|
if !!!(a as bool) {
|
||||||
|
say("not not (a as bool)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branch_and(a: bool, b: bool) {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
if a && b {
|
||||||
|
say("both");
|
||||||
|
} else {
|
||||||
|
say("not both");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn branch_or(a: bool, b: bool) {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
if a || b {
|
||||||
|
say("either");
|
||||||
|
} else {
|
||||||
|
say("neither");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn say(message: &str) {
|
||||||
|
core::hint::black_box(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
for a in [false, true, true] {
|
||||||
|
branch_not(a);
|
||||||
|
branch_not_as(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
for a in [false, true, true, true, true] {
|
||||||
|
for b in [false, true, true] {
|
||||||
|
branch_and(a, b);
|
||||||
|
branch_or(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
74
tests/coverage/branch_while.cov-map
Normal file
74
tests/coverage/branch_while.cov-map
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
Function name: branch_while::while_cond
|
||||||
|
Raw bytes (33): 0x[01, 01, 02, 05, 09, 03, 09, 05, 01, 0c, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 10, 09, 00, 11, 02, 06, 06, 03, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2)
|
||||||
|
Number of file 0 mappings: 5
|
||||||
|
- Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 9) to (start + 0, 18)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 11) to (start + 0, 16)
|
||||||
|
= (c1 + c2)
|
||||||
|
- Code(Counter(2)) at (prev + 0, 17) to (start + 2, 6)
|
||||||
|
- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= ((c1 + c2) - c2)
|
||||||
|
|
||||||
|
Function name: branch_while::while_cond_not
|
||||||
|
Raw bytes (33): 0x[01, 01, 02, 05, 09, 03, 09, 05, 01, 15, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 14, 09, 00, 15, 02, 06, 06, 03, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 2
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(2)
|
||||||
|
Number of file 0 mappings: 5
|
||||||
|
- Code(Counter(0)) at (prev + 21, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 9) to (start + 0, 18)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 1, 11) to (start + 0, 20)
|
||||||
|
= (c1 + c2)
|
||||||
|
- Code(Counter(2)) at (prev + 0, 21) to (start + 2, 6)
|
||||||
|
- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2)
|
||||||
|
= ((c1 + c2) - c2)
|
||||||
|
|
||||||
|
Function name: branch_while::while_op_and
|
||||||
|
Raw bytes (40): 0x[01, 01, 03, 05, 09, 03, 0d, 11, 0d, 06, 01, 1e, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 06, 00, 14, 00, 19, 09, 00, 1a, 03, 06, 0b, 04, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 3
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Counter(2)
|
||||||
|
- expression 1 operands: lhs = Expression(0, Add), rhs = Counter(3)
|
||||||
|
- expression 2 operands: lhs = Counter(4), rhs = Counter(3)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 30, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 9) to (start + 1, 18)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 16)
|
||||||
|
= (c1 + c2)
|
||||||
|
- Code(Expression(1, Sub)) at (prev + 0, 20) to (start + 0, 25)
|
||||||
|
= ((c1 + c2) - c3)
|
||||||
|
- Code(Counter(2)) at (prev + 0, 26) to (start + 3, 6)
|
||||||
|
- Code(Expression(2, Add)) at (prev + 4, 1) to (start + 0, 2)
|
||||||
|
= (c4 + c3)
|
||||||
|
|
||||||
|
Function name: branch_while::while_op_or
|
||||||
|
Raw bytes (46): 0x[01, 01, 06, 05, 0f, 09, 0d, 03, 09, 09, 0d, 16, 0d, 03, 09, 06, 01, 29, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 16, 00, 14, 00, 19, 0f, 00, 1a, 03, 06, 12, 04, 01, 00, 02]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => global file 1
|
||||||
|
Number of expressions: 6
|
||||||
|
- expression 0 operands: lhs = Counter(1), rhs = Expression(3, Add)
|
||||||
|
- expression 1 operands: lhs = Counter(2), rhs = Counter(3)
|
||||||
|
- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2)
|
||||||
|
- expression 3 operands: lhs = Counter(2), rhs = Counter(3)
|
||||||
|
- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(3)
|
||||||
|
- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(2)
|
||||||
|
Number of file 0 mappings: 6
|
||||||
|
- Code(Counter(0)) at (prev + 41, 1) to (start + 1, 16)
|
||||||
|
- Code(Counter(1)) at (prev + 3, 9) to (start + 1, 18)
|
||||||
|
- Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 16)
|
||||||
|
= (c1 + (c2 + c3))
|
||||||
|
- Code(Expression(5, Sub)) at (prev + 0, 20) to (start + 0, 25)
|
||||||
|
= ((c1 + (c2 + c3)) - c2)
|
||||||
|
- Code(Expression(3, Add)) at (prev + 0, 26) to (start + 3, 6)
|
||||||
|
= (c2 + c3)
|
||||||
|
- Code(Expression(4, Sub)) at (prev + 4, 1) to (start + 0, 2)
|
||||||
|
= (((c1 + (c2 + c3)) - c2) - c3)
|
||||||
|
|
60
tests/coverage/branch_while.coverage
Normal file
60
tests/coverage/branch_while.coverage
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
LL| |#![feature(coverage_attribute)]
|
||||||
|
LL| |//@ edition: 2021
|
||||||
|
LL| |
|
||||||
|
LL| |//@ llvm-cov-flags: --show-branches=count
|
||||||
|
LL| |
|
||||||
|
LL| |macro_rules! no_merge {
|
||||||
|
LL| | () => {
|
||||||
|
LL| | for _ in 0..1 {}
|
||||||
|
LL| | };
|
||||||
|
LL| |}
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn while_cond() {
|
||||||
|
LL| 1| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 1| let mut a = 8;
|
||||||
|
LL| 9| while a > 0 {
|
||||||
|
LL| 8| a -= 1;
|
||||||
|
LL| 8| }
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn while_cond_not() {
|
||||||
|
LL| 1| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 1| let mut a = 8;
|
||||||
|
LL| 9| while !(a == 0) {
|
||||||
|
LL| 8| a -= 1;
|
||||||
|
LL| 8| }
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn while_op_and() {
|
||||||
|
LL| 1| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 1| let mut a = 8;
|
||||||
|
LL| 1| let mut b = 4;
|
||||||
|
LL| 5| while a > 0 && b > 0 {
|
||||||
|
LL| 4| a -= 1;
|
||||||
|
LL| 4| b -= 1;
|
||||||
|
LL| 4| }
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn while_op_or() {
|
||||||
|
LL| 1| no_merge!();
|
||||||
|
LL| |
|
||||||
|
LL| 1| let mut a = 4;
|
||||||
|
LL| 1| let mut b = 8;
|
||||||
|
LL| 9| while a > 0 || b > 0 {
|
||||||
|
^5
|
||||||
|
LL| 8| a -= 1;
|
||||||
|
LL| 8| b -= 1;
|
||||||
|
LL| 8| }
|
||||||
|
LL| 1|}
|
||||||
|
LL| |
|
||||||
|
LL| |#[coverage(off)]
|
||||||
|
LL| |fn main() {
|
||||||
|
LL| | while_cond();
|
||||||
|
LL| | while_cond_not();
|
||||||
|
LL| | while_op_and();
|
||||||
|
LL| | while_op_or();
|
||||||
|
LL| |}
|
||||||
|
|
58
tests/coverage/branch_while.rs
Normal file
58
tests/coverage/branch_while.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#![feature(coverage_attribute)]
|
||||||
|
//@ edition: 2021
|
||||||
|
|
||||||
|
//@ llvm-cov-flags: --show-branches=count
|
||||||
|
|
||||||
|
macro_rules! no_merge {
|
||||||
|
() => {
|
||||||
|
for _ in 0..1 {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn while_cond() {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
let mut a = 8;
|
||||||
|
while a > 0 {
|
||||||
|
a -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn while_cond_not() {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
let mut a = 8;
|
||||||
|
while !(a == 0) {
|
||||||
|
a -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn while_op_and() {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
let mut a = 8;
|
||||||
|
let mut b = 4;
|
||||||
|
while a > 0 && b > 0 {
|
||||||
|
a -= 1;
|
||||||
|
b -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn while_op_or() {
|
||||||
|
no_merge!();
|
||||||
|
|
||||||
|
let mut a = 4;
|
||||||
|
let mut b = 8;
|
||||||
|
while a > 0 || b > 0 {
|
||||||
|
a -= 1;
|
||||||
|
b -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[coverage(off)]
|
||||||
|
fn main() {
|
||||||
|
while_cond();
|
||||||
|
while_cond_not();
|
||||||
|
while_op_and();
|
||||||
|
while_op_or();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user