diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-03 12:08:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-03 12:08:51 +0100 |
| commit | 10a8446344cd31c57dfbdd46b2ea6f15a8e55f85 (patch) | |
| tree | 732e6b774715b9c3c9a5786b201a4c8017c09547 | |
| parent | e522d088fd07b87b254ce722328d0cd5cc0cd2f4 (diff) | |
| parent | afe190204b0cdb37a2e09dd0899421cdad98e262 (diff) | |
| download | rust-10a8446344cd31c57dfbdd46b2ea6f15a8e55f85.tar.gz rust-10a8446344cd31c57dfbdd46b2ea6f15a8e55f85.zip | |
Rollup merge of #132437 - Zalathar:inline-mixed-regression, r=jieyouxu
coverage: Regression test for inlining into an uninstrumented crate Regression test for #132395, after I was able to figure out a simple way to reproduce it. See also #132436. In addition to confirming that there is no ICE, this test also demonstrates that the affected code is undercounted, because executing the inlined copy doesn't increment coverage counters.
| -rw-r--r-- | tests/coverage/auxiliary/inline_mixed_helper.rs | 13 | ||||
| -rw-r--r-- | tests/coverage/inline_mixed.rs | 19 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/coverage/auxiliary/inline_mixed_helper.rs b/tests/coverage/auxiliary/inline_mixed_helper.rs new file mode 100644 index 00000000000..1e91ab8ce7c --- /dev/null +++ b/tests/coverage/auxiliary/inline_mixed_helper.rs @@ -0,0 +1,13 @@ +//@ edition: 2021 +//@ compile-flags: -Cinstrument-coverage=on + +#[inline] +pub fn inline_me() {} + +#[inline(never)] +pub fn no_inlining_please() {} + +pub fn generic<T>() {} + +// FIXME(#132436): Even though this doesn't ICE, it still produces coverage +// reports that undercount the affected code. diff --git a/tests/coverage/inline_mixed.rs b/tests/coverage/inline_mixed.rs new file mode 100644 index 00000000000..163cc7d7d6c --- /dev/null +++ b/tests/coverage/inline_mixed.rs @@ -0,0 +1,19 @@ +//@ edition: 2021 +//@ compile-flags: -Cinstrument-coverage=off +//@ ignore-coverage-run +//@ aux-crate: inline_mixed_helper=inline_mixed_helper.rs + +// Regression test for <https://github.com/rust-lang/rust/pull/132395>. +// Various forms of cross-crate inlining can cause coverage statements to be +// inlined into crates that are being built without coverage instrumentation. +// At the very least, we need to not ICE when that happens. + +fn main() { + inline_mixed_helper::inline_me(); + inline_mixed_helper::no_inlining_please(); + inline_mixed_helper::generic::<u32>(); +} + +// FIXME(#132437): We currently don't test this in coverage-run mode, because +// whether or not it produces a `.profraw` file appears to differ between +// platforms. |
