rust/src/test/mir-opt
Rich Kadel 5239a68e72 add spans to injected coverage counters
added regions with counter expressions and counters.

Added codegen_llvm/coverageinfo mod for upcoming coverage map

Move coverage region collection to CodegenCx finalization

Moved from `query coverageinfo` (renamed from `query coverage_data`),
as discussed in the PR at:

https://github.com/rust-lang/rust/pull/73684#issuecomment-649882503

Address merge conflict in MIR instrument_coverage test

The MIR test output format changed for int types.

moved debug messages out of block.rs

This makes the block.rs calls to add coverage mapping data to the
CodegenCx much more concise and readable.

move coverage intrinsic handling into llvm impl

I realized that having half of the coverage intrinsic handling in
`rustc_codegen_ssa` and half in `rustc_codegen_llvm` meant that any
non-llvm backend would be bound to the same decisions about how the
coverage-related MIR terminators should be handled.

To fix this, I moved the non-codegen portion of coverage intrinsic
handling into its own trait, and implemented it in `rustc_codegen_llvm`
alongside `codegen_intrinsic_call`.

I also added the (required?) stubs for the new intrinsics to
`IntrepretCx::emulate_intrinsic()`, to ensure calls to this function do
not fail if called with these new but known intrinsics.

address PR Feedback on 28 June 2020 2:48pm PDT
2020-06-29 12:31:25 -07:00
..
address-of Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
array-index-is-temporary Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
basic_assignment Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
box_expr Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
byte_slice Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
combine_array_len Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
const-promotion-extern-static Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
const_allocation Pointer printing: do not print 0 offset 2020-05-12 13:30:50 +02:00
const_allocation2 Pointer printing: do not print 0 offset 2020-05-12 13:30:50 +02:00
const_allocation3 Pointer printing: do not print 0 offset 2020-05-12 13:30:50 +02:00
const_prop Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
const_prop_miscompile Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
copy_propagation Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
copy_propagation_arg Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
deaggregator_test Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
deaggregator_test_enum Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
deaggregator_test_enum_2 Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
deaggregator_test_multiple Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
exponential-or Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
fn-ptr-shim Add test 2020-06-15 20:54:40 +02:00
generator-drop-cleanup Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
generator-storage-dead-unwind Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
generator-tiny Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
graphviz Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
inline Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
instrument_coverage add spans to injected coverage counters 2020-06-29 12:31:25 -07:00
issue-38669 rename FalseEdges -> FalseEdge 2020-06-07 10:12:21 +02:00
issue-41110 Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
issue-41697 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
issue-41888 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
issue-49232 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
issue-62289 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
issue-72181 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
issue-72181-1 pretty/mir: const value enums with no variants 2020-06-19 14:46:01 +01:00
loop_test Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
match-arm-scopes Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
match_false_edges Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
match_test Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
nll rename FalseEdges -> FalseEdge 2020-06-07 10:12:21 +02:00
no-drop-for-inactive-variant Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
no-spurious-drop-after-call Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
nrvo-simple Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
packed-struct-drop-aligned Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
remove-never-const Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
remove_fake_borrows Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
retag Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simple-match Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify-arm Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify-arm-identity Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify-locals-fixedpoint Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify-locals-removes-unused-consts Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify-locals-removes-unused-discriminant-reads Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify_cfg rename FalseEdges -> FalseEdge 2020-06-07 10:12:21 +02:00
simplify_if Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
simplify_match Changed simplify_match output query because it had become outdated 2020-04-28 00:53:48 -04:00
simplify_try Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
simplify_try_if_let Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
slice-drop-shim Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
storage_live_dead_in_statics Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
storage_ranges Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
tls-access Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
uniform_array_move_out Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
uninhabited-enum Emit basic block ids for statements and terminators in MIR only in -Zverbose mode 2020-04-27 15:16:12 +02:00
uninhabited_enum_branching Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
unreachable Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
unreachable_asm Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
unreachable_asm_2 Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
unreachable_diverging Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
unusual-item-types Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
while-storage Revert "Bless mir-opt tests" 2020-06-04 11:29:10 -04:00
address-of.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
array-index-is-temporary.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
basic_assignment.rs Enable --blessing of MIR dumps 2020-03-26 15:26:33 +01:00
box_expr.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
byte_slice.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
combine_array_len.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
const-promotion-extern-static.rs Enable --blessing of MIR dumps 2020-03-26 15:26:33 +01:00
const_allocation.rs Enable --blessing of MIR dumps 2020-03-26 15:26:33 +01:00
const_allocation2.rs Enable --blessing of MIR dumps 2020-03-26 15:26:33 +01:00
const_allocation3.rs Enable --blessing of MIR dumps 2020-03-26 15:26:33 +01:00
const_prop_miscompile.rs The const propagator cannot trace references. 2020-06-23 10:18:14 +02:00
copy_propagation.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
copy_propagation_arg.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
deaggregator_test.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
deaggregator_test_enum.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
deaggregator_test_enum_2.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
deaggregator_test_multiple.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
exponential-or.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
fn-ptr-shim.rs Add test 2020-06-15 20:54:40 +02:00
generator-drop-cleanup.rs Ignore generator-drop-cleanup on wasm32-bare 2020-04-17 20:37:34 +02:00
generator-storage-dead-unwind.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
generator-tiny.rs Fix test 2020-04-29 01:21:24 +01:00
graphviz.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
instrument_coverage.rs Ensure profiling runtime for -Zinstrument-coverage 2020-06-16 18:48:46 -07:00
issue-38669.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
issue-41110.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
issue-41697.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
issue-41888.rs Add ignore-wasm32-bare to mir-opt tests that need it. 2020-04-08 18:58:49 +00:00
issue-49232.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
issue-62289.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
issue-72181-1.rs pretty/mir: const value enums with no variants 2020-06-19 14:46:01 +01:00
issue-72181.rs pretty/mir: const value enums with no variants 2020-06-19 14:46:01 +01:00
loop_test.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
match-arm-scopes.rs Add ignore-wasm32-bare to mir-opt tests that need it. 2020-04-08 18:58:49 +00:00
match_false_edges.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
match_test.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
no-drop-for-inactive-variant.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
no-spurious-drop-after-call.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
nrvo-simple.rs Add simple NRVO test 2020-05-16 17:15:24 -07:00
packed-struct-drop-aligned.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
README.md Remove old mir-opt test format. 2020-04-07 18:02:11 +00:00
remove-never-const.rs Adjust name of never typed const test 2020-04-23 18:07:36 -03:00
remove_fake_borrows.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
retag.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
return_an_array.rs Remove licenses 2018-12-25 21:08:33 -07:00
simple-match.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
simplify-arm-identity.rs Allow Locals to be propagated into and from, but restricted to their own block 2020-04-28 00:44:50 -04:00
simplify-arm.rs Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1 2020-05-11 20:31:02 -04:00
simplify-locals-fixedpoint.rs Add test case 2020-04-15 14:34:23 -04:00
simplify-locals-removes-unused-consts.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
simplify-locals-removes-unused-discriminant-reads.rs Add EMIR_MIR_FOR_EACH_BIT_WIDTH to failing test 2020-06-15 21:09:49 -04:00
simplify_cfg.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
simplify_if.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
simplify_match.rs Changed simplify_match output query because it had become outdated 2020-04-28 00:53:48 -04:00
simplify_try.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
simplify_try_if_let.rs Modify SimplifyArmIdentity so it can trigger on mir-opt-level=1 2020-05-11 20:31:02 -04:00
slice-drop-shim.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
storage_live_dead_in_statics.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
storage_ranges.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
tls-access.rs Make TLS accesses explicit in MIR 2020-05-30 12:59:05 +02:00
uniform_array_move_out.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
uninhabited-enum.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
uninhabited_enum_branching.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
unreachable.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
unreachable_asm.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
unreachable_asm_2.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
unreachable_diverging.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00
unusual-item-types.rs Add EMIT_MIR_FOR_EACH_BIT_WIDTH to tests that need it. 2020-04-07 17:49:14 +00:00
while-storage.rs --bless all mir-opt tests. 2020-04-07 15:09:01 +00:00

This folder contains tests for MIR optimizations.

The mir-opt test format emits MIR to extra files that you can automatically update by specifying --bless on the command line (just like ui tests updating .stderr files).

--blessable test format

By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the presence of pointers in constants or other bit width dependent things. In that case you can add

// EMIT_MIR_FOR_EACH_BIT_WIDTH

to your test, causing separate files to be generated for 32bit and 64bit systems.

Emit a diff of the mir for a specific optimization

This is what you want most often when you want to see how an optimization changes the MIR.

// EMIT_MIR $file_name_of_some_mir_dump.diff

Emit mir after a specific optimization

Use this if you are just interested in the final state after an optimization.

// EMIT_MIR $file_name_of_some_mir_dump.after.mir

Emit mir before a specific optimization

This exists mainly for completeness and is rarely useful.

// EMIT_MIR $file_name_of_some_mir_dump.before.mir