From 9fa37bb7830513eb7e09e56d56da78b6bfd5ebc2 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 10 Mar 2024 21:20:27 +1100 Subject: [PATCH] coverage: Enable branch coverage in the branch coverage tests --- tests/coverage/branch_generics.cov-map | 27 ++-- tests/coverage/branch_generics.coverage | 16 +- tests/coverage/branch_generics.rs | 2 +- tests/coverage/branch_if.cov-map | 186 +++++++++++++++--------- tests/coverage/branch_if.coverage | 31 +++- tests/coverage/branch_if.rs | 2 +- tests/coverage/branch_while.cov-map | 70 ++++++--- tests/coverage/branch_while.coverage | 16 +- tests/coverage/branch_while.rs | 2 +- 9 files changed, 247 insertions(+), 105 deletions(-) diff --git a/tests/coverage/branch_generics.cov-map b/tests/coverage/branch_generics.cov-map index ff8bb632a54f6..719e97efad455 100644 --- a/tests/coverage/branch_generics.cov-map +++ b/tests/coverage/branch_generics.cov-map @@ -1,43 +1,52 @@ 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] +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] 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 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6) +- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) + true = c1 + false = (c0 - c1) +- Code(Counter(1)) at (prev + 0, 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:: -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] +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] 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 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6) +- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) + true = c1 + false = (c0 - c1) +- Code(Counter(1)) at (prev + 0, 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:: -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] +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] 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 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Code(Counter(1)) at (prev + 1, 37) to (start + 2, 6) +- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) + true = c1 + false = (c0 - c1) +- Code(Counter(1)) at (prev + 0, 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) diff --git a/tests/coverage/branch_generics.coverage b/tests/coverage/branch_generics.coverage index cfbd2d3f4bd46..0f23ba2d6a488 100644 --- a/tests/coverage/branch_generics.coverage +++ b/tests/coverage/branch_generics.coverage @@ -1,10 +1,15 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 - LL| | + LL| |//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch LL| |//@ llvm-cov-flags: --show-branches=count LL| | LL| 3|fn print_size() { LL| 3| if std::mem::size_of::() > 4 { + ------------------ + | Branch (LL:8): [True: 0, False: 1] + | Branch (LL:8): [True: 0, False: 1] + | Branch (LL:8): [True: 1, False: 0] + ------------------ LL| 1| println!("size > 4"); LL| 2| } else { LL| 2| println!("size <= 4"); @@ -14,6 +19,9 @@ | branch_generics::print_size::<()>: | LL| 1|fn print_size() { | LL| 1| if std::mem::size_of::() > 4 { + | ------------------ + | | Branch (LL:8): [True: 0, False: 1] + | ------------------ | LL| 0| println!("size > 4"); | LL| 1| } else { | LL| 1| println!("size <= 4"); @@ -23,6 +31,9 @@ | branch_generics::print_size::: | LL| 1|fn print_size() { | LL| 1| if std::mem::size_of::() > 4 { + | ------------------ + | | Branch (LL:8): [True: 0, False: 1] + | ------------------ | LL| 0| println!("size > 4"); | LL| 1| } else { | LL| 1| println!("size <= 4"); @@ -32,6 +43,9 @@ | branch_generics::print_size::: | LL| 1|fn print_size() { | LL| 1| if std::mem::size_of::() > 4 { + | ------------------ + | | Branch (LL:8): [True: 1, False: 0] + | ------------------ | LL| 1| println!("size > 4"); | LL| 1| } else { | LL| 0| println!("size <= 4"); diff --git a/tests/coverage/branch_generics.rs b/tests/coverage/branch_generics.rs index ad1f5be33c4b1..4a7b9e7c50bb3 100644 --- a/tests/coverage/branch_generics.rs +++ b/tests/coverage/branch_generics.rs @@ -1,6 +1,6 @@ #![feature(coverage_attribute)] //@ edition: 2021 - +//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch //@ llvm-cov-flags: --show-branches=count fn print_size() { diff --git a/tests/coverage/branch_if.cov-map b/tests/coverage/branch_if.cov-map index 6fb5ef767148f..0dbfd92541b03 100644 --- a/tests/coverage/branch_if.cov-map +++ b/tests/coverage/branch_if.cov-map @@ -1,121 +1,167 @@ 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] +Raw bytes (56): 0x[01, 01, 04, 05, 09, 0d, 02, 11, 0f, 0d, 02, 08, 01, 2b, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 00, 0d, 00, 0e, 20, 11, 0d, 00, 0d, 00, 0e, 11, 00, 0f, 02, 06, 0f, 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 +Number of expressions: 4 +- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Counter(3), rhs = Expression(0, Sub) +- expression 2 operands: lhs = Counter(4), rhs = Expression(3, Add) +- expression 3 operands: lhs = Counter(3), rhs = Expression(0, Sub) +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 43, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 8) to (start + 0, 9) + true = c2 + false = (c1 - c2) - Code(Counter(2)) at (prev + 0, 13) to (start + 0, 14) +- Branch { true: Counter(4), false: Counter(3) } at (prev + 0, 13) to (start + 0, 14) + true = c4 + false = c3 - 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(3, Add)) at (prev + 2, 12) to (start + 2, 6) + = (c3 + (c1 - c2)) - Code(Expression(2, Add)) at (prev + 3, 1) to (start + 0, 2) - = (c4 + ((c1 - c2) + c3)) + = (c4 + (c3 + (c1 - c2))) 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] +Raw bytes (224): 0x[01, 01, 29, 05, 09, 09, 02, a3, 01, 0d, 09, 02, a3, 01, 0d, 09, 02, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 15, 8e, 01, 93, 01, 15, 11, 96, 01, 9b, 01, 11, 0d, 9e, 01, a3, 01, 0d, 09, 02, 12, 01, 0c, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 09, 01, 09, 00, 11, 02, 01, 06, 00, 07, a3, 01, 01, 08, 00, 0a, 20, 9e, 01, 0d, 00, 08, 00, 0a, 9e, 01, 00, 0b, 02, 06, 0d, 02, 06, 00, 07, 9b, 01, 01, 08, 00, 0b, 20, 11, 96, 01, 00, 08, 00, 0b, 11, 00, 0c, 02, 06, 96, 01, 02, 06, 00, 07, 93, 01, 01, 08, 00, 0c, 20, 8e, 01, 15, 00, 08, 00, 0c, 8e, 01, 00, 0d, 02, 06, 15, 02, 06, 00, 07, 8b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 29 +Number of expressions: 41 - 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 2 operands: lhs = Expression(40, 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 4 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 6 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 7 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 9 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 10 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 11 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 12 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 13 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 14 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 15 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 16 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 17 operands: lhs = Counter(4), rhs = Expression(37, Sub) +- expression 18 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 19 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 20 operands: lhs = Expression(40, 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 +- expression 22 operands: lhs = Expression(36, Add), rhs = Counter(5) +- expression 23 operands: lhs = Counter(4), rhs = Expression(37, Sub) +- expression 24 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 25 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 26 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 27 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 28 operands: lhs = Expression(36, Add), rhs = Counter(5) +- expression 29 operands: lhs = Counter(4), rhs = Expression(37, Sub) +- expression 30 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 31 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 32 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 33 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 34 operands: lhs = Counter(5), rhs = Expression(35, Sub) +- expression 35 operands: lhs = Expression(36, Add), rhs = Counter(5) +- expression 36 operands: lhs = Counter(4), rhs = Expression(37, Sub) +- expression 37 operands: lhs = Expression(38, Add), rhs = Counter(4) +- expression 38 operands: lhs = Counter(3), rhs = Expression(39, Sub) +- expression 39 operands: lhs = Expression(40, Add), rhs = Counter(3) +- expression 40 operands: lhs = Counter(2), rhs = Expression(0, Sub) +Number of file 0 mappings: 18 - Code(Counter(0)) at (prev + 12, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 8) to (start + 0, 9) + true = c2 + false = (c1 - c2) - 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) +- Code(Expression(40, Add)) at (prev + 1, 8) to (start + 0, 10) = (c2 + (c1 - c2)) -- Code(Expression(27, Sub)) at (prev + 0, 11) to (start + 2, 6) +- Branch { true: Expression(39, Sub), false: Counter(3) } at (prev + 0, 8) to (start + 0, 10) + true = ((c2 + (c1 - c2)) - c3) + false = c3 +- Code(Expression(39, 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) +- Code(Expression(38, Add)) at (prev + 1, 8) to (start + 0, 11) = (c3 + ((c2 + (c1 - c2)) - c3)) +- Branch { true: Counter(4), false: Expression(37, Sub) } at (prev + 0, 8) to (start + 0, 11) + true = c4 + false = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) - Code(Counter(4)) at (prev + 0, 12) to (start + 2, 6) -- Code(Expression(25, Sub)) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(37, 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) +- Code(Expression(36, 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) +- Branch { true: Expression(35, Sub), false: Counter(5) } at (prev + 0, 8) to (start + 0, 12) + true = ((c4 + ((c3 + ((c2 + (c1 - c2)) - c3)) - c4)) - c5) + false = c5 +- Code(Expression(35, 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) +- Code(Expression(34, 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] +Raw bytes (124): 0x[01, 01, 16, 05, 09, 09, 02, 57, 0d, 09, 02, 57, 0d, 09, 02, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 4f, 11, 0d, 52, 57, 0d, 09, 02, 11, 4a, 4f, 11, 0d, 52, 57, 0d, 09, 02, 0e, 01, 1d, 01, 01, 10, 05, 03, 08, 00, 14, 20, 02, 09, 00, 08, 00, 14, 02, 00, 15, 02, 06, 09, 02, 06, 00, 07, 57, 01, 08, 00, 15, 20, 0d, 52, 00, 08, 00, 15, 0d, 00, 16, 02, 06, 52, 02, 06, 00, 07, 4f, 01, 08, 00, 16, 20, 4a, 11, 00, 08, 00, 16, 4a, 00, 17, 02, 06, 11, 02, 06, 00, 07, 47, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 16 +Number of expressions: 22 - 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 2 operands: lhs = Expression(21, 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 +- expression 4 operands: lhs = Expression(21, Add), rhs = Counter(3) +- expression 5 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 6 operands: lhs = Counter(3), rhs = Expression(20, Sub) +- expression 7 operands: lhs = Expression(21, Add), rhs = Counter(3) +- expression 8 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 9 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 10 operands: lhs = Counter(3), rhs = Expression(20, Sub) +- expression 11 operands: lhs = Expression(21, Add), rhs = Counter(3) +- expression 12 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 13 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 14 operands: lhs = Counter(3), rhs = Expression(20, Sub) +- expression 15 operands: lhs = Expression(21, Add), rhs = Counter(3) +- expression 16 operands: lhs = Counter(2), rhs = Expression(0, Sub) +- expression 17 operands: lhs = Counter(4), rhs = Expression(18, Sub) +- expression 18 operands: lhs = Expression(19, Add), rhs = Counter(4) +- expression 19 operands: lhs = Counter(3), rhs = Expression(20, Sub) +- expression 20 operands: lhs = Expression(21, Add), rhs = Counter(3) +- expression 21 operands: lhs = Counter(2), rhs = Expression(0, Sub) +Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 29, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 20) +- Branch { true: Expression(0, Sub), false: Counter(2) } at (prev + 0, 8) to (start + 0, 20) + true = (c1 - c2) + false = c2 - 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) +- Code(Expression(21, Add)) at (prev + 1, 8) to (start + 0, 21) = (c2 + (c1 - c2)) +- Branch { true: Counter(3), false: Expression(20, Sub) } at (prev + 0, 8) to (start + 0, 21) + true = c3 + false = ((c2 + (c1 - c2)) - c3) - Code(Counter(3)) at (prev + 0, 22) to (start + 2, 6) -- Code(Expression(14, Sub)) at (prev + 2, 6) to (start + 0, 7) +- Code(Expression(20, 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) +- Code(Expression(19, 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) +- Branch { true: Expression(18, Sub), false: Counter(4) } at (prev + 0, 8) to (start + 0, 22) + true = ((c3 + ((c2 + (c1 - c2)) - c3)) - c4) + false = c4 +- Code(Expression(18, 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) +- Code(Expression(17, 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] +Raw bytes (56): 0x[01, 01, 04, 05, 09, 09, 0d, 0f, 11, 09, 0d, 08, 01, 35, 01, 01, 10, 05, 03, 08, 00, 09, 20, 09, 02, 00, 08, 00, 09, 02, 00, 0d, 00, 0e, 20, 0d, 11, 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 @@ -123,11 +169,17 @@ Number of expressions: 4 - 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 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 53, 1) to (start + 1, 16) - Code(Counter(1)) at (prev + 3, 8) to (start + 0, 9) +- Branch { true: Counter(2), false: Expression(0, Sub) } at (prev + 0, 8) to (start + 0, 9) + true = c2 + false = (c1 - c2) - Code(Expression(0, Sub)) at (prev + 0, 13) to (start + 0, 14) = (c1 - c2) +- Branch { true: Counter(3), false: Counter(4) } at (prev + 0, 13) to (start + 0, 14) + true = c3 + false = c4 - 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) diff --git a/tests/coverage/branch_if.coverage b/tests/coverage/branch_if.coverage index babefb51d3f21..566bc7aa57638 100644 --- a/tests/coverage/branch_if.coverage +++ b/tests/coverage/branch_if.coverage @@ -1,6 +1,6 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 - LL| | + LL| |//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch LL| |//@ llvm-cov-flags: --show-branches=count LL| | LL| |macro_rules! no_merge { @@ -13,16 +13,28 @@ LL| 3| no_merge!(); LL| | LL| 3| if a { + ------------------ + | Branch (LL:8): [True: 2, False: 1] + ------------------ LL| 2| say("a") LL| 1| } LL| 3| if !a { + ------------------ + | Branch (LL:8): [True: 1, False: 2] + ------------------ LL| 1| say("not a"); LL| 2| } LL| 3| if !!a { + ------------------ + | Branch (LL:8): [True: 2, False: 1] + ------------------ LL| 2| say("not not a"); LL| 2| } ^1 LL| 3| if !!!a { + ------------------ + | Branch (LL:8): [True: 1, False: 2] + ------------------ LL| 1| say("not not not a"); LL| 2| } LL| 3|} @@ -31,13 +43,22 @@ LL| 3| no_merge!(); LL| | LL| 3| if !(a as bool) { + ------------------ + | Branch (LL:8): [True: 1, False: 2] + ------------------ LL| 1| say("not (a as bool)"); LL| 2| } LL| 3| if !!(a as bool) { + ------------------ + | Branch (LL:8): [True: 2, False: 1] + ------------------ LL| 2| say("not not (a as bool)"); LL| 2| } ^1 LL| 3| if !!!(a as bool) { + ------------------ + | Branch (LL:8): [True: 1, False: 2] + ------------------ LL| 1| say("not not (a as bool)"); LL| 2| } LL| 3|} @@ -47,6 +68,10 @@ LL| | LL| 15| if a && b { ^12 + ------------------ + | Branch (LL:8): [True: 12, False: 3] + | Branch (LL:13): [True: 8, False: 4] + ------------------ LL| 8| say("both"); LL| 8| } else { LL| 7| say("not both"); @@ -58,6 +83,10 @@ LL| | LL| 15| if a || b { ^3 + ------------------ + | Branch (LL:8): [True: 12, False: 3] + | Branch (LL:13): [True: 2, False: 1] + ------------------ LL| 14| say("either"); LL| 14| } else { LL| 1| say("neither"); diff --git a/tests/coverage/branch_if.rs b/tests/coverage/branch_if.rs index 55ef159ebdfc5..e2ad44caaf4bb 100644 --- a/tests/coverage/branch_if.rs +++ b/tests/coverage/branch_if.rs @@ -1,6 +1,6 @@ #![feature(coverage_attribute)] //@ edition: 2021 - +//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch //@ llvm-cov-flags: --show-branches=count macro_rules! no_merge { diff --git a/tests/coverage/branch_while.cov-map b/tests/coverage/branch_while.cov-map index 63a7c438163ea..d5f54f1abea20 100644 --- a/tests/coverage/branch_while.cov-map +++ b/tests/coverage/branch_while.cov-map @@ -1,74 +1,98 @@ 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] +Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 0c, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 10, 20, 09, 0a, 00, 0b, 00, 10, 09, 00, 11, 02, 06, 0a, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 3 - 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 +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of file 0 mappings: 6 - 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) +- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 11) to (start + 0, 16) + true = c2 + false = ((c1 + c2) - c2) - Code(Counter(2)) at (prev + 0, 17) to (start + 2, 6) -- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2) +- Code(Expression(2, 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] +Raw bytes (42): 0x[01, 01, 03, 05, 09, 03, 09, 03, 09, 06, 01, 15, 01, 01, 10, 05, 03, 09, 00, 12, 03, 01, 0b, 00, 14, 20, 09, 0a, 00, 0b, 00, 14, 09, 00, 15, 02, 06, 0a, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 +Number of expressions: 3 - 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 +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of file 0 mappings: 6 - 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) +- Branch { true: Counter(2), false: Expression(2, Sub) } at (prev + 0, 11) to (start + 0, 20) + true = c2 + false = ((c1 + c2) - c2) - Code(Counter(2)) at (prev + 0, 21) to (start + 2, 6) -- Code(Expression(1, Sub)) at (prev + 3, 1) to (start + 0, 2) +- Code(Expression(2, 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] +Raw bytes (56): 0x[01, 01, 04, 05, 09, 03, 0d, 03, 0d, 11, 0d, 08, 01, 1e, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 0a, 0d, 00, 0b, 00, 10, 0a, 00, 14, 00, 19, 20, 09, 11, 00, 14, 00, 19, 09, 00, 1a, 03, 06, 0f, 04, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 3 +Number of expressions: 4 - 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 +- expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 3 operands: lhs = Counter(4), rhs = Counter(3) +Number of file 0 mappings: 8 - 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) +- Branch { true: Expression(2, Sub), false: Counter(3) } at (prev + 0, 11) to (start + 0, 16) + true = ((c1 + c2) - c3) + false = c3 +- Code(Expression(2, Sub)) at (prev + 0, 20) to (start + 0, 25) = ((c1 + c2) - c3) +- Branch { true: Counter(2), false: Counter(4) } at (prev + 0, 20) to (start + 0, 25) + true = c2 + false = c4 - Code(Counter(2)) at (prev + 0, 26) to (start + 3, 6) -- Code(Expression(2, Add)) at (prev + 4, 1) to (start + 0, 2) +- Code(Expression(3, 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] +Raw bytes (66): 0x[01, 01, 09, 05, 1b, 09, 0d, 03, 09, 03, 09, 22, 0d, 03, 09, 09, 0d, 22, 0d, 03, 09, 08, 01, 29, 01, 01, 10, 05, 03, 09, 01, 12, 03, 02, 0b, 00, 10, 20, 09, 22, 00, 0b, 00, 10, 22, 00, 14, 00, 19, 20, 0d, 1e, 00, 14, 00, 19, 1b, 00, 1a, 03, 06, 1e, 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) +Number of expressions: 9 +- expression 0 operands: lhs = Counter(1), rhs = Expression(6, 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 3 operands: lhs = Expression(0, Add), rhs = Counter(2) +- expression 4 operands: lhs = Expression(8, Sub), rhs = Counter(3) - expression 5 operands: lhs = Expression(0, Add), rhs = Counter(2) -Number of file 0 mappings: 6 +- expression 6 operands: lhs = Counter(2), rhs = Counter(3) +- expression 7 operands: lhs = Expression(8, Sub), rhs = Counter(3) +- expression 8 operands: lhs = Expression(0, Add), rhs = Counter(2) +Number of file 0 mappings: 8 - 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) +- Branch { true: Counter(2), false: Expression(8, Sub) } at (prev + 0, 11) to (start + 0, 16) + true = c2 + false = ((c1 + (c2 + c3)) - c2) +- Code(Expression(8, 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) +- Branch { true: Counter(3), false: Expression(7, Sub) } at (prev + 0, 20) to (start + 0, 25) + true = c3 + false = (((c1 + (c2 + c3)) - c2) - c3) +- Code(Expression(6, Add)) at (prev + 0, 26) to (start + 3, 6) = (c2 + c3) -- Code(Expression(4, Sub)) at (prev + 4, 1) to (start + 0, 2) +- Code(Expression(7, Sub)) at (prev + 4, 1) to (start + 0, 2) = (((c1 + (c2 + c3)) - c2) - c3) diff --git a/tests/coverage/branch_while.coverage b/tests/coverage/branch_while.coverage index d2351a7de09a2..b3ec423d2b7de 100644 --- a/tests/coverage/branch_while.coverage +++ b/tests/coverage/branch_while.coverage @@ -1,6 +1,6 @@ LL| |#![feature(coverage_attribute)] LL| |//@ edition: 2021 - LL| | + LL| |//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch LL| |//@ llvm-cov-flags: --show-branches=count LL| | LL| |macro_rules! no_merge { @@ -14,6 +14,9 @@ LL| | LL| 1| let mut a = 8; LL| 9| while a > 0 { + ------------------ + | Branch (LL:11): [True: 8, False: 1] + ------------------ LL| 8| a -= 1; LL| 8| } LL| 1|} @@ -23,6 +26,9 @@ LL| | LL| 1| let mut a = 8; LL| 9| while !(a == 0) { + ------------------ + | Branch (LL:11): [True: 8, False: 1] + ------------------ LL| 8| a -= 1; LL| 8| } LL| 1|} @@ -33,6 +39,10 @@ LL| 1| let mut a = 8; LL| 1| let mut b = 4; LL| 5| while a > 0 && b > 0 { + ------------------ + | Branch (LL:11): [True: 5, False: 0] + | Branch (LL:20): [True: 4, False: 1] + ------------------ LL| 4| a -= 1; LL| 4| b -= 1; LL| 4| } @@ -45,6 +55,10 @@ LL| 1| let mut b = 8; LL| 9| while a > 0 || b > 0 { ^5 + ------------------ + | Branch (LL:11): [True: 4, False: 5] + | Branch (LL:20): [True: 4, False: 1] + ------------------ LL| 8| a -= 1; LL| 8| b -= 1; LL| 8| } diff --git a/tests/coverage/branch_while.rs b/tests/coverage/branch_while.rs index 99e9a798eff5f..07685e35c6697 100644 --- a/tests/coverage/branch_while.rs +++ b/tests/coverage/branch_while.rs @@ -1,6 +1,6 @@ #![feature(coverage_attribute)] //@ edition: 2021 - +//@ compile-flags: -Zunstable-options -Cinstrument-coverage=branch //@ llvm-cov-flags: --show-branches=count macro_rules! no_merge {