Skip to content

Commit

Permalink
Rollup merge of rust-lang#132437 - Zalathar:inline-mixed-regression, …
Browse files Browse the repository at this point in the history
…r=jieyouxu

coverage: Regression test for inlining into an uninstrumented crate

Regression test for rust-lang#132395, after I was able to figure out a simple way to reproduce it. See also rust-lang#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.
  • Loading branch information
GuillaumeGomez authored Nov 2, 2024
2 parents 9633dce + afe1902 commit 6202fcb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/coverage/auxiliary/inline_mixed_helper.rs
Original file line number Diff line number Diff line change
@@ -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.
19 changes: 19 additions & 0 deletions tests/coverage/inline_mixed.rs
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 6202fcb

Please sign in to comment.