forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage: Regression test for rust-lang#17012 (bad counter IDs in map…
…pings)
- Loading branch information
Showing
4 changed files
with
298 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,98 @@ | ||
Function name: <bad_counter_ids::Foo as core::cmp::PartialEq>::eq | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 11, 00, 1a] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 12, 17) to (start + 0, 26) | ||
|
||
Function name: <bad_counter_ids::Foo as core::fmt::Debug>::fmt | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 0a, 00, 0f] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 12, 10) to (start + 0, 15) | ||
|
||
Function name: bad_counter_ids::eq_bad | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 23, 01, 02, 1f, 00, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 35, 1) to (start + 2, 31) | ||
- Code(Zero) at (prev + 3, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::eq_bad_message | ||
Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 28, 01, 02, 0f, 02, 02, 20, 00, 2b, 00, 01, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 1 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
Number of file 0 mappings: 3 | ||
- Code(Counter(0)) at (prev + 40, 1) to (start + 2, 15) | ||
- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43) | ||
= (c0 - c1) | ||
- Code(Zero) at (prev + 1, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::eq_good | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 0f, 01, 02, 1f, 05, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 31) | ||
- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::eq_good_message | ||
Raw bytes (19): 0x[01, 01, 00, 03, 01, 14, 01, 02, 0f, 00, 02, 20, 00, 2b, 05, 01, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 3 | ||
- Code(Counter(0)) at (prev + 20, 1) to (start + 2, 15) | ||
- Code(Zero) at (prev + 2, 32) to (start + 0, 43) | ||
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::ne_bad | ||
Raw bytes (14): 0x[01, 01, 00, 02, 01, 2d, 01, 02, 1f, 00, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 45, 1) to (start + 2, 31) | ||
- Code(Zero) at (prev + 3, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::ne_bad_message | ||
Raw bytes (19): 0x[01, 01, 00, 03, 01, 32, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 3 | ||
- Code(Counter(0)) at (prev + 50, 1) to (start + 2, 15) | ||
- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43) | ||
- Code(Zero) at (prev + 1, 1) to (start + 0, 2) | ||
|
||
Function name: bad_counter_ids::ne_good | ||
Raw bytes (16): 0x[01, 01, 01, 01, 05, 02, 01, 19, 01, 02, 1f, 02, 03, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 1 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
Number of file 0 mappings: 2 | ||
- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 31) | ||
- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2) | ||
= (c0 - c1) | ||
|
||
Function name: bad_counter_ids::ne_good_message | ||
Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 1e, 01, 02, 0f, 00, 02, 20, 00, 2b, 02, 01, 01, 00, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 1 | ||
- expression 0 operands: lhs = Counter(0), rhs = Counter(1) | ||
Number of file 0 mappings: 3 | ||
- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 15) | ||
- Code(Zero) at (prev + 2, 32) to (start + 0, 43) | ||
- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2) | ||
= (c0 - c1) | ||
|
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,66 @@ | ||
#![feature(coverage_attribute)] | ||
// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 | ||
|
||
// Regression test for <https://github.com/rust-lang/rust/issues/117012>. | ||
// | ||
// If some coverage counters were removed by MIR optimizations, we need to take | ||
// care not to refer to those counter IDs in coverage mappings, and instead | ||
// replace them with a constant zero value. If we don't, `llvm-cov` might see | ||
// a too-large counter ID and silently discard the entire function from its | ||
// coverage reports. | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
struct Foo(u32); | ||
|
||
fn eq_good() { | ||
println!("a"); | ||
assert_eq!(Foo(1), Foo(1)); | ||
} | ||
|
||
fn eq_good_message() { | ||
println!("b"); | ||
assert_eq!(Foo(1), Foo(1), "message b"); | ||
} | ||
|
||
fn ne_good() { | ||
println!("c"); | ||
assert_ne!(Foo(1), Foo(3)); | ||
} | ||
|
||
fn ne_good_message() { | ||
println!("d"); | ||
assert_ne!(Foo(1), Foo(3), "message d"); | ||
} | ||
|
||
fn eq_bad() { | ||
println!("e"); | ||
assert_eq!(Foo(1), Foo(3)); | ||
} | ||
|
||
fn eq_bad_message() { | ||
println!("f"); | ||
assert_eq!(Foo(1), Foo(3), "message f"); | ||
} | ||
|
||
fn ne_bad() { | ||
println!("g"); | ||
assert_ne!(Foo(1), Foo(1)); | ||
} | ||
|
||
fn ne_bad_message() { | ||
println!("h"); | ||
assert_ne!(Foo(1), Foo(1), "message h"); | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
eq_good(); | ||
eq_good_message(); | ||
ne_good(); | ||
ne_good_message(); | ||
|
||
assert!(std::panic::catch_unwind(eq_bad).is_err()); | ||
assert!(std::panic::catch_unwind(eq_bad_message).is_err()); | ||
assert!(std::panic::catch_unwind(ne_bad).is_err()); | ||
assert!(std::panic::catch_unwind(ne_bad_message).is_err()); | ||
} |
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,68 @@ | ||
LL| |#![feature(coverage_attribute)] | ||
LL| |// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 | ||
LL| | | ||
LL| |// Regression test for <https://github.com/rust-lang/rust/issues/117012>. | ||
LL| |// | ||
LL| |// If some coverage counters were removed by MIR optimizations, we need to take | ||
LL| |// care not to refer to those counter IDs in coverage mappings, and instead | ||
LL| |// replace them with a constant zero value. If we don't, `llvm-cov` might see | ||
LL| |// a too-large counter ID and silently discard the entire function from its | ||
LL| |// coverage reports. | ||
LL| | | ||
LL| 8|#[derive(Debug, PartialEq, Eq)] | ||
LL| |struct Foo(u32); | ||
LL| | | ||
LL| 1|fn eq_good() { | ||
LL| 1| println!("a"); | ||
LL| 1| assert_eq!(Foo(1), Foo(1)); | ||
LL| 1|} | ||
LL| | | ||
LL| 1|fn eq_good_message() { | ||
LL| 1| println!("b"); | ||
LL| 1| assert_eq!(Foo(1), Foo(1), "message b"); | ||
^0 | ||
LL| 1|} | ||
LL| | | ||
LL| |fn ne_good() { | ||
LL| | println!("c"); | ||
LL| | assert_ne!(Foo(1), Foo(3)); | ||
LL| |} | ||
LL| | | ||
LL| |fn ne_good_message() { | ||
LL| | println!("d"); | ||
LL| | assert_ne!(Foo(1), Foo(3), "message d"); | ||
LL| |} | ||
LL| | | ||
LL| 1|fn eq_bad() { | ||
LL| 1| println!("e"); | ||
LL| 1| assert_eq!(Foo(1), Foo(3)); | ||
LL| 0|} | ||
LL| | | ||
LL| |fn eq_bad_message() { | ||
LL| | println!("f"); | ||
LL| | assert_eq!(Foo(1), Foo(3), "message f"); | ||
LL| |} | ||
LL| | | ||
LL| 1|fn ne_bad() { | ||
LL| 1| println!("g"); | ||
LL| 1| assert_ne!(Foo(1), Foo(1)); | ||
LL| 0|} | ||
LL| | | ||
LL| 1|fn ne_bad_message() { | ||
LL| 1| println!("h"); | ||
LL| 1| assert_ne!(Foo(1), Foo(1), "message h"); | ||
LL| 0|} | ||
LL| | | ||
LL| |#[coverage(off)] | ||
LL| |fn main() { | ||
LL| | eq_good(); | ||
LL| | eq_good_message(); | ||
LL| | ne_good(); | ||
LL| | ne_good_message(); | ||
LL| | | ||
LL| | assert!(std::panic::catch_unwind(eq_bad).is_err()); | ||
LL| | assert!(std::panic::catch_unwind(eq_bad_message).is_err()); | ||
LL| | assert!(std::panic::catch_unwind(ne_bad).is_err()); | ||
LL| | assert!(std::panic::catch_unwind(ne_bad_message).is_err()); | ||
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,66 @@ | ||
#![feature(coverage_attribute)] | ||
// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 | ||
|
||
// Regression test for <https://github.com/rust-lang/rust/issues/117012>. | ||
// | ||
// If some coverage counters were removed by MIR optimizations, we need to take | ||
// care not to refer to those counter IDs in coverage mappings, and instead | ||
// replace them with a constant zero value. If we don't, `llvm-cov` might see | ||
// a too-large counter ID and silently discard the entire function from its | ||
// coverage reports. | ||
|
||
#[derive(Debug, PartialEq, Eq)] | ||
struct Foo(u32); | ||
|
||
fn eq_good() { | ||
println!("a"); | ||
assert_eq!(Foo(1), Foo(1)); | ||
} | ||
|
||
fn eq_good_message() { | ||
println!("b"); | ||
assert_eq!(Foo(1), Foo(1), "message b"); | ||
} | ||
|
||
fn ne_good() { | ||
println!("c"); | ||
assert_ne!(Foo(1), Foo(3)); | ||
} | ||
|
||
fn ne_good_message() { | ||
println!("d"); | ||
assert_ne!(Foo(1), Foo(3), "message d"); | ||
} | ||
|
||
fn eq_bad() { | ||
println!("e"); | ||
assert_eq!(Foo(1), Foo(3)); | ||
} | ||
|
||
fn eq_bad_message() { | ||
println!("f"); | ||
assert_eq!(Foo(1), Foo(3), "message f"); | ||
} | ||
|
||
fn ne_bad() { | ||
println!("g"); | ||
assert_ne!(Foo(1), Foo(1)); | ||
} | ||
|
||
fn ne_bad_message() { | ||
println!("h"); | ||
assert_ne!(Foo(1), Foo(1), "message h"); | ||
} | ||
|
||
#[coverage(off)] | ||
fn main() { | ||
eq_good(); | ||
eq_good_message(); | ||
ne_good(); | ||
ne_good_message(); | ||
|
||
assert!(std::panic::catch_unwind(eq_bad).is_err()); | ||
assert!(std::panic::catch_unwind(eq_bad_message).is_err()); | ||
assert!(std::panic::catch_unwind(ne_bad).is_err()); | ||
assert!(std::panic::catch_unwind(ne_bad_message).is_err()); | ||
} |