rust/tests/coverage
bors d2d24e395a Auto merge of #123602 - cjgillot:gvn-borrowed, r=oli-obk
Account for immutably borrowed locals in MIR copy-prop and GVN

For the most part, we consider that immutably borrowed `Freeze` locals still fulfill SSA conditions. As the borrow is immutable, any use of the local will have the value given by the single assignment, and there can be no surprise.

This allows copy-prop to merge a non-borrowed local with a borrowed local. We chose to keep copy-classes heads unborrowed, as those may be easier to optimize in later passes.

This also allows to GVN the value behind an immutable borrow. If a SSA local is borrowed, dereferencing that borrow is equivalent to copying the local's value: re-executing the assignment between the borrow and the dereference would be UB.

r? `@ghost` for perf
2024-05-03 21:50:13 +00:00
..
auxiliary coverage: Remove all unstable values of -Cinstrument-coverage 2024-03-13 11:14:09 +11:00
branch coverage: Branch coverage tests for match arms 2024-04-22 21:55:33 +10:00
abort.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
abort.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
abort.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
assert_not.cov-map coverage: Regression test for assert!(!false) 2023-12-16 20:58:04 +11:00
assert_not.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
assert_not.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
assert.cov-map
assert.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
assert.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async2.cov-map Enable GVN by default. 2023-12-24 20:08:57 +00:00
async2.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async2.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async_block.cov-map coverage: Add a test for async blocks 2023-12-20 18:48:04 +11:00
async_block.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async_block.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
async.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
async.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
bad_counter_ids.cov-map coverage: Use normal edition: headers in coverage tests 2024-02-02 11:17:05 +11:00
bad_counter_ids.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
bad_counter_ids.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
bench.cov-map Add #[coverage(off)] to closures introduced by #[test]/#[bench] 2024-01-21 23:17:00 +11:00
bench.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
bench.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_bug.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
closure_bug.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
closure_bug.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
closure_macro_async.cov-map coverage: Eagerly deduplicate covspans with the same span 2024-02-21 21:25:35 +11:00
closure_macro_async.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_macro_async.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_macro.cov-map coverage: Eagerly deduplicate covspans with the same span 2024-02-21 21:25:35 +11:00
closure_macro.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_macro.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_unit_return.cov-map coverage: Discard spans that fill the entire function body 2024-02-16 10:57:03 +11:00
closure_unit_return.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure_unit_return.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure.cov-map Enable by default. 2024-02-09 21:13:51 +00:00
closure.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
closure.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
color.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
color.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
conditions.cov-map coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
conditions.coverage coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
conditions.rs coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
continue.cov-map coverage: Simplify building coverage expressions based on sums 2023-11-25 12:29:20 +11:00
continue.coverage
continue.rs
coroutine.cov-map Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine.coverage Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coroutine.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
coverage_attr_closure.cov-map coverage: Discard spans that fill the entire function body 2024-02-16 10:57:03 +11:00
coverage_attr_closure.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
coverage_attr_closure.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
dead_code.cov-map
dead_code.coverage
dead_code.rs
drop_trait.cov-map
drop_trait.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
drop_trait.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
fn_sig_into_try.cov-map coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
fn_sig_into_try.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
fn_sig_into_try.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
generics.cov-map
generics.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
generics.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
if_else.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if_else.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if_else.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if_not.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if_not.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
if_not.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
if.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
if.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
ignore_map.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
ignore_map.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
ignore_run.cov-map Allow tests to ignore individual test modes 2024-01-05 13:42:54 +11:00
ignore_run.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
inline-dead.cov-map coverage: Discard spans that fill the entire function body 2024-02-16 10:57:03 +11:00
inline-dead.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
inline-dead.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
inline.cov-map coverage: Skip spans that can't be un-expanded back to the function body 2023-12-03 12:35:33 +11:00
inline.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
inline.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
inner_items.cov-map
inner_items.coverage
inner_items.rs
issue-83601.cov-map Dereference immutable borrows in GVN. 2024-04-20 19:22:13 +00:00
issue-83601.coverage coverage: Don't instrument #[automatically_derived] functions 2024-01-22 12:18:57 +11:00
issue-83601.rs
issue-84561.cov-map Dereference immutable borrows in GVN. 2024-04-20 19:22:13 +00:00
issue-84561.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-84561.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-85461.cov-map
issue-85461.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-85461.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-93054.cov-map coverage: Use normal edition: headers in coverage tests 2024-02-02 11:17:05 +11:00
issue-93054.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
issue-93054.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
lazy_boolean.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
lazy_boolean.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
lazy_boolean.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
let_else_loop.cov-map coverage: Regression test for ICE triggered by self-loops 2024-03-20 18:14:35 +11:00
let_else_loop.coverage coverage: Remove incorrect assertions from counter allocation 2024-03-20 18:22:15 +11:00
let_else_loop.rs coverage: Remove incorrect assertions from counter allocation 2024-03-20 18:22:15 +11:00
long_and_wide.cov-map
long_and_wide.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
long_and_wide.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
loop_break_value.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
loop_break_value.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
loop_break_value.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
loops_branches.cov-map coverage: Simplify building coverage expressions based on sums 2023-11-25 12:29:20 +11:00
loops_branches.coverage
loops_branches.rs
macro_in_closure.cov-map coverage: Test for closure body that is a single bang-macro 2024-02-05 10:07:18 +11:00
macro_in_closure.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
macro_in_closure.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
macro_name_span.cov-map coverage: Discard spans that fill the entire function body 2024-02-16 10:57:03 +11:00
macro_name_span.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
macro_name_span.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
match_or_pattern.cov-map
match_or_pattern.coverage
match_or_pattern.rs
mcdc_if.cov-map coverage. Add basic tests for MC/DC 2024-04-20 00:34:40 +08:00
mcdc_if.coverage coverage. Add basic tests for MC/DC 2024-04-20 00:34:40 +08:00
mcdc_if.rs coverage. Add basic tests for MC/DC 2024-04-20 00:34:40 +08:00
mcdc_nested_if.cov-map tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
mcdc_nested_if.coverage tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
mcdc_nested_if.rs tests(mcdc-coverage): Add tests for nested decision structures in mcdc_nested_if.rs 2024-04-29 09:13:41 +00:00
nested_loops.cov-map
nested_loops.coverage
nested_loops.rs
no_cov_crate.cov-map
no_cov_crate.coverage
no_cov_crate.rs
no_spans_if_not.cov-map macro_rules: Preserve all metavariable spans in a global side table 2024-02-18 11:19:24 +03:00
no_spans_if_not.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
no_spans_if_not.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
no_spans.cov-map macro_rules: Preserve all metavariable spans in a global side table 2024-02-18 11:19:24 +03:00
no_spans.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
no_spans.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
overflow.cov-map
overflow.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
overflow.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
panic_unwind.cov-map
panic_unwind.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
panic_unwind.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
partial_eq.cov-map coverage: Don't instrument #[automatically_derived] functions 2024-01-22 12:18:57 +11:00
partial_eq.coverage coverage: Don't instrument #[automatically_derived] functions 2024-01-22 12:18:57 +11:00
partial_eq.rs coverage: Format all remaining tests 2024-01-18 10:42:37 +11:00
README.md coverage: Rename the run-coverage test mode to coverage-run 2023-11-08 16:41:24 +11:00
simple_loop.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
simple_loop.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
simple_loop.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
simple_match.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
simple_match.coverage coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
simple_match.rs coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
sort_groups.cov-map
sort_groups.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
sort_groups.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
test_harness.cov-map Add #[coverage(off)] to closures introduced by #[test]/#[bench] 2024-01-21 23:17:00 +11:00
test_harness.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
test_harness.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
thin-lto.cov-map coverage: Format all remaining tests 2024-01-18 10:42:37 +11:00
thin-lto.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
thin-lto.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
tight_inf_loop.cov-map
tight_inf_loop.coverage
tight_inf_loop.rs
trivial.cov-map
trivial.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
trivial.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
try_error_result.cov-map Enable by default. 2024-02-09 21:13:51 +00:00
try_error_result.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
try_error_result.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unicode.cov-map coverage: Discard spans that fill the entire function body 2024-02-16 10:57:03 +11:00
unicode.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unicode.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unreachable.cov-map Eliminate UbCheck for non-standard libraries 2024-03-27 21:02:40 +08:00
unreachable.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unreachable.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
unused_mod.cov-map
unused_mod.coverage
unused_mod.rs
unused.cov-map
unused.coverage
unused.rs
uses_crate.cov-map
uses_crate.coverage coverage: Remove all unstable values of -Cinstrument-coverage 2024-03-13 11:14:09 +11:00
uses_crate.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
uses_inline_crate.cov-map
uses_inline_crate.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
uses_inline_crate.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
while_early_ret.cov-map coverage: Add #[rustfmt::skip] to tests with non-standard formatting 2024-01-16 15:56:37 +11:00
while_early_ret.coverage [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
while_early_ret.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
while.cov-map coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
while.coverage coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
while.rs coverage: Tweak individual tests to be unaffected by rustfmt 2024-01-16 16:14:27 +11:00
yield.cov-map Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield.coverage Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00
yield.rs Error on using yield without also using #[coroutine] on the closure 2024-04-24 08:05:29 +00:00

The tests in this directory are shared by two different test modes, and can be run in multiple different ways:

  • ./x.py test coverage-map (compiles to LLVM IR and checks coverage mappings)
  • ./x.py test coverage-run (runs a test binary and checks its coverage report)
  • ./x.py test coverage (runs both coverage-map and coverage-run)

Maintenance note

These tests can be sensitive to small changes in MIR spans or MIR control flow, especially in HIR-to-MIR lowering or MIR optimizations.

If you haven't touched the coverage code directly, and the tests still pass in coverage-run mode, then it should usually be OK to just re-bless the mappings as necessary with ./x.py test coverage-map --bless, without worrying too much about the exact changes.