-
Notifications
You must be signed in to change notification settings - Fork 13.4k
coverage: Consistently remove unused counter IDs from expressions/mappings #117123
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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, 00, 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 = Zero | ||
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 - Zero) | ||
- 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, 00, 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 = Zero | ||
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 - Zero) | ||
|
||
Function name: bad_counter_ids::ne_good_message | ||
Raw bytes (21): 0x[01, 01, 01, 01, 00, 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 = Zero | ||
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 - Zero) | ||
|
This file contains hidden or 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()); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.