-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
Function name: branch::if_and | ||
Raw bytes (77): 0x[01, 01, 0b, 01, 05, 05, 02, 2b, 09, 05, 02, 0d, 26, 2b, 09, 05, 02, 11, 23, 0d, 26, 2b, 09, 05, 02, 09, 20, 05, 02, 06, 10, 00, 14, 01, 0d, 01, 01, 23, 2b, 03, 08, 00, 09, 20, 09, 26, 00, 08, 00, 09, 09, 00, 0d, 00, 0e, 20, 11, 0d, 00, 0d, 00, 0e, 11, 00, 0f, 02, 06, 23, 02, 0c, 02, 06, 1f, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 11 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 2 operands: lhs = Expression(10, Add), rhs = Counter(2) | ||
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 4 operands: lhs = Counter(3), rhs = Expression(9, Sub) | ||
- expression 5 operands: lhs = Expression(10, Add), rhs = Counter(2) | ||
- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 7 operands: lhs = Counter(4), rhs = Expression(8, Add) | ||
- expression 8 operands: lhs = Counter(3), rhs = Expression(9, Sub) | ||
- expression 9 operands: lhs = Expression(10, Add), rhs = Counter(2) | ||
- expression 10 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
Number of file 0 mappings: 9 | ||
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 6, 16) to (start + 0, 20) | ||
true = c1 | ||
false = (c0 - c1) | ||
- Code(Counter(0)) at (prev + 13, 1) to (start + 1, 35) | ||
- Code(Expression(10, Add)) at (prev + 3, 8) to (start + 0, 9) | ||
= (c1 + (c0 - c1)) | ||
- Branch { true: Counter(2), false: Expression(9, Sub) } at (prev + 0, 8) to (start + 0, 9) | ||
true = c2 | ||
false = ((c1 + (c0 - 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(8, Add)) at (prev + 2, 12) to (start + 2, 6) | ||
= (c3 + ((c1 + (c0 - c1)) - c2)) | ||
- Code(Expression(7, Add)) at (prev + 3, 1) to (start + 0, 2) | ||
= (c4 + (c3 + ((c1 + (c0 - c1)) - c2))) | ||
|
||
Function name: branch::if_let | ||
Raw bytes (50): 0x[01, 01, 07, 01, 05, 05, 02, 1b, 09, 05, 02, 09, 16, 1b, 09, 05, 02, 06, 20, 05, 02, 06, 10, 00, 14, 01, 21, 01, 01, 23, 1b, 03, 13, 00, 17, 09, 00, 18, 02, 06, 16, 02, 0c, 02, 06, 13, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 7 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 2 operands: lhs = Expression(6, Add), rhs = Counter(2) | ||
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 4 operands: lhs = Counter(2), rhs = Expression(5, Sub) | ||
- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(2) | ||
- expression 6 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
Number of file 0 mappings: 6 | ||
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 6, 16) to (start + 0, 20) | ||
true = c1 | ||
false = (c0 - c1) | ||
- Code(Counter(0)) at (prev + 33, 1) to (start + 1, 35) | ||
- Code(Expression(6, Add)) at (prev + 3, 19) to (start + 0, 23) | ||
= (c1 + (c0 - c1)) | ||
- Code(Counter(2)) at (prev + 0, 24) to (start + 2, 6) | ||
- Code(Expression(5, Sub)) at (prev + 2, 12) to (start + 2, 6) | ||
= ((c1 + (c0 - c1)) - c2) | ||
- Code(Expression(4, Add)) at (prev + 3, 1) to (start + 0, 2) | ||
= (c2 + ((c1 + (c0 - c1)) - c2)) | ||
|
||
Function name: branch::if_not | ||
Raw bytes (61): 0x[01, 01, 09, 01, 05, 05, 02, 23, 09, 05, 02, 23, 09, 05, 02, 09, 1e, 23, 09, 05, 02, 07, 20, 05, 02, 06, 10, 00, 14, 01, 03, 01, 01, 23, 23, 03, 09, 00, 0d, 20, 09, 1e, 00, 09, 00, 0d, 1e, 00, 0e, 02, 06, 09, 02, 0c, 02, 06, 1b, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 9 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 2 operands: lhs = Expression(8, Add), rhs = Counter(2) | ||
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 4 operands: lhs = Expression(8, Add), rhs = Counter(2) | ||
- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 6 operands: lhs = Counter(2), rhs = Expression(7, Sub) | ||
- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(2) | ||
- expression 8 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
Number of file 0 mappings: 7 | ||
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 6, 16) to (start + 0, 20) | ||
true = c1 | ||
false = (c0 - c1) | ||
- Code(Counter(0)) at (prev + 3, 1) to (start + 1, 35) | ||
- Code(Expression(8, Add)) at (prev + 3, 9) to (start + 0, 13) | ||
= (c1 + (c0 - c1)) | ||
- Branch { true: Counter(2), false: Expression(7, Sub) } at (prev + 0, 9) to (start + 0, 13) | ||
true = c2 | ||
false = ((c1 + (c0 - c1)) - c2) | ||
- Code(Expression(7, Sub)) at (prev + 0, 14) to (start + 2, 6) | ||
= ((c1 + (c0 - c1)) - c2) | ||
- Code(Counter(2)) at (prev + 2, 12) to (start + 2, 6) | ||
- Code(Expression(6, Add)) at (prev + 3, 1) to (start + 0, 2) | ||
= (c2 + ((c1 + (c0 - c1)) - c2)) | ||
|
||
Function name: branch::if_or | ||
Raw bytes (75): 0x[01, 01, 0a, 01, 05, 05, 02, 17, 09, 05, 02, 17, 09, 05, 02, 09, 0d, 09, 0d, 27, 11, 09, 0d, 09, 20, 05, 02, 06, 10, 00, 14, 01, 17, 01, 01, 23, 17, 03, 08, 00, 09, 20, 09, 12, 00, 08, 00, 09, 12, 00, 0d, 00, 0e, 20, 27, 11, 00, 0d, 00, 0e, 27, 00, 0f, 02, 06, 11, 02, 0c, 02, 06, 23, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 10 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 2 operands: lhs = Expression(5, Add), rhs = Counter(2) | ||
- expression 3 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 4 operands: lhs = Expression(5, Add), rhs = Counter(2) | ||
- expression 5 operands: lhs = Counter(1), rhs = Expression(0, Sub) | ||
- expression 6 operands: lhs = Counter(2), rhs = Counter(3) | ||
- expression 7 operands: lhs = Counter(2), rhs = Counter(3) | ||
- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(4) | ||
- expression 9 operands: lhs = Counter(2), rhs = Counter(3) | ||
Number of file 0 mappings: 9 | ||
- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 6, 16) to (start + 0, 20) | ||
true = c1 | ||
false = (c0 - c1) | ||
- Code(Counter(0)) at (prev + 23, 1) to (start + 1, 35) | ||
- Code(Expression(5, Add)) at (prev + 3, 8) to (start + 0, 9) | ||
= (c1 + (c0 - c1)) | ||
- Branch { true: Counter(2), false: Expression(4, Sub) } at (prev + 0, 8) to (start + 0, 9) | ||
true = c2 | ||
false = ((c1 + (c0 - c1)) - c2) | ||
- Code(Expression(4, Sub)) at (prev + 0, 13) to (start + 0, 14) | ||
= ((c1 + (c0 - c1)) - c2) | ||
- Branch { true: Expression(9, Add), false: Counter(4) } at (prev + 0, 13) to (start + 0, 14) | ||
true = (c2 + c3) | ||
false = c4 | ||
- Code(Expression(9, Add)) at (prev + 0, 15) to (start + 2, 6) | ||
= (c2 + c3) | ||
- Code(Counter(4)) at (prev + 2, 12) to (start + 2, 6) | ||
- Code(Expression(8, Add)) at (prev + 3, 1) to (start + 0, 2) | ||
= ((c2 + c3) + c4) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
LL| |#![feature(coverage_attribute)] | ||
LL| |// edition: 2021 | ||
LL| |// compile-flags: -Zunstable-options -Cinstrument-coverage=branch | ||
LL| | | ||
LL| |macro_rules! do_not_merge_with_signature { | ||
LL| | () => { if true {} else {} }; | ||
------------------ | ||
| Branch (LL:16): [True: 15, False: 0] | ||
------------------ | ||
| Branch (LL:16): [True: 15, False: 0] | ||
------------------ | ||
| Branch (LL:16): [True: 15, False: 0] | ||
------------------ | ||
| Branch (LL:16): [True: 15, False: 0] | ||
------------------ | ||
LL| |} | ||
LL| | | ||
LL| 15|fn if_not(cond: bool) { | ||
LL| 15| do_not_merge_with_signature!(); | ||
LL| | | ||
LL| 15| if !cond { | ||
------------------ | ||
| Branch (LL:9): [True: 10, False: 5] | ||
------------------ | ||
LL| 5| println!("cond was false"); | ||
LL| 10| } else { | ||
LL| 10| println!("cond was true"); | ||
LL| 10| } | ||
LL| 15|} | ||
LL| | | ||
LL| 15|fn if_and(a: bool, b: bool) { | ||
LL| 15| do_not_merge_with_signature!(); | ||
LL| | | ||
LL| 15| if a && b { | ||
^12 | ||
------------------ | ||
| Branch (LL:8): [True: 12, False: 3] | ||
| Branch (LL:13): [True: 8, False: 4] | ||
------------------ | ||
LL| 8| println!("both"); | ||
LL| 8| } else { | ||
LL| 7| println!("not both"); | ||
LL| 7| } | ||
LL| 15|} | ||
LL| | | ||
LL| 15|fn if_or(a: bool, b: bool) { | ||
LL| 15| do_not_merge_with_signature!(); | ||
LL| | | ||
LL| 15| if a || b { | ||
^3 | ||
------------------ | ||
| Branch (LL:8): [True: 12, False: 3] | ||
| Branch (LL:13): [True: 14, False: 1] | ||
------------------ | ||
LL| 14| println!("either"); | ||
LL| 14| } else { | ||
LL| 1| println!("neither"); | ||
LL| 1| } | ||
LL| 15|} | ||
LL| | | ||
LL| 15|fn if_let(cond: bool) { | ||
LL| 15| do_not_merge_with_signature!(); | ||
LL| | | ||
LL| 15| if let true = cond { | ||
LL| 10| println!("true"); | ||
LL| 10| } else { | ||
LL| 5| println!("false"); | ||
LL| 5| } | ||
LL| 15|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | let truthy = std::hint::black_box(true); | ||
LL| | let falsy = std::hint::black_box(false); | ||
LL| | | ||
LL| | for _ in 0..10 { | ||
LL| | if_not(truthy); | ||
LL| | if_let(truthy); | ||
LL| | } | ||
LL| | for _ in 0..5 { | ||
LL| | if_not(falsy); | ||
LL| | if_let(falsy); | ||
LL| | } | ||
LL| | | ||
LL| | for _ in 0..8 { | ||
LL| | if_and(truthy, truthy); | ||
LL| | if_or(truthy, truthy); | ||
LL| | } | ||
LL| | for _ in 0..4 { | ||
LL| | if_and(truthy, falsy); | ||
LL| | if_or(truthy, falsy); | ||
LL| | } | ||
LL| | for _ in 0..2 { | ||
LL| | if_and(falsy, truthy); | ||
LL| | if_or(falsy, truthy); | ||
LL| | } | ||
LL| | for _ in 0..1 { | ||
LL| | if_and(falsy, falsy); | ||
LL| | if_or(falsy, falsy); | ||
LL| | } | ||
LL| |} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#![feature(coverage_attribute)] | ||
// edition: 2021 | ||
// compile-flags: -Zunstable-options -Cinstrument-coverage=branch | ||
|
||
macro_rules! do_not_merge_with_signature { | ||
() => { if true {} else {} }; | ||
} | ||
|
||
fn if_not(cond: bool) { | ||
do_not_merge_with_signature!(); | ||
|
||
if !cond { | ||
println!("cond was false"); | ||
} else { | ||
println!("cond was true"); | ||
} | ||
} | ||
|
||
fn if_and(a: bool, b: bool) { | ||
do_not_merge_with_signature!(); | ||
|
||
if a && b { | ||
println!("both"); | ||
} else { | ||
println!("not both"); | ||
} | ||
} | ||
|
||
fn if_or(a: bool, b: bool) { | ||
do_not_merge_with_signature!(); | ||
|
||
if a || b { | ||
println!("either"); | ||
} else { | ||
println!("neither"); | ||
} | ||
} | ||
|
||
fn if_let(cond: bool) { | ||
do_not_merge_with_signature!(); | ||
|
||
if let true = cond { | ||
println!("true"); | ||
} else { | ||
println!("false"); | ||
} | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
let truthy = std::hint::black_box(true); | ||
let falsy = std::hint::black_box(false); | ||
|
||
for _ in 0..10 { | ||
if_not(truthy); | ||
if_let(truthy); | ||
} | ||
for _ in 0..5 { | ||
if_not(falsy); | ||
if_let(falsy); | ||
} | ||
|
||
for _ in 0..8 { | ||
if_and(truthy, truthy); | ||
if_or(truthy, truthy); | ||
} | ||
for _ in 0..4 { | ||
if_and(truthy, falsy); | ||
if_or(truthy, falsy); | ||
} | ||
for _ in 0..2 { | ||
if_and(falsy, truthy); | ||
if_or(falsy, truthy); | ||
} | ||
for _ in 0..1 { | ||
if_and(falsy, falsy); | ||
if_or(falsy, falsy); | ||
} | ||
} |