From f3f159315d70b223e1aa1eedf5d93fb6d0c6da94 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Fri, 1 Nov 2024 12:47:53 +1100 Subject: [PATCH] coverage: Regression test for inlining into an uninstrumented crate --- tests/coverage/auxiliary/inline_mixed_helper.rs | 13 +++++++++++++ tests/coverage/inline_mixed.coverage | 14 ++++++++++++++ tests/coverage/inline_mixed.rs | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/coverage/auxiliary/inline_mixed_helper.rs create mode 100644 tests/coverage/inline_mixed.coverage create mode 100644 tests/coverage/inline_mixed.rs diff --git a/tests/coverage/auxiliary/inline_mixed_helper.rs b/tests/coverage/auxiliary/inline_mixed_helper.rs new file mode 100644 index 0000000000000..1e91ab8ce7c03 --- /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() {} + +// 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.coverage b/tests/coverage/inline_mixed.coverage new file mode 100644 index 0000000000000..5012dc7e6c3f2 --- /dev/null +++ b/tests/coverage/inline_mixed.coverage @@ -0,0 +1,14 @@ + LL| |//@ edition: 2021 + LL| |//@ compile-flags: -Cinstrument-coverage=on + LL| | + LL| |#[inline] + LL| 0|pub fn inline_me() {} + LL| | + LL| |#[inline(never)] + LL| 1|pub fn no_inlining_please() {} + LL| | + LL| 0|pub fn generic() {} + LL| | + LL| |// FIXME(#132436): Even though this doesn't ICE, it still produces coverage + LL| |// 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 0000000000000..caf924c80069c --- /dev/null +++ b/tests/coverage/inline_mixed.rs @@ -0,0 +1,14 @@ +//@ edition: 2021 +//@ compile-flags: -Cinstrument-coverage=off +//@ aux-crate: inline_mixed_helper=inline_mixed_helper.rs + +// Regression test for . +// 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::(); +}