rust/src/test/mir-opt
Dylan DPC 2d8f6389d0
Rollup merge of #68524 - jonas-schievink:generator-resume-arguments, r=Zoxc
Generator Resume Arguments

cc https://github.com/rust-lang/rust/issues/43122 and https://github.com/rust-lang/rust/issues/56974

Blockers:
* [x] Fix miscompilation when resume argument is live across a yield point (https://github.com/rust-lang/rust/pull/68524#issuecomment-578459069)
* [x] Fix 10% compile time regression in `await-call-tree` benchmarks (https://github.com/rust-lang/rust/pull/68524#issuecomment-578487162)
  * [x] Fix remaining 1-3% regression (https://github.com/rust-lang/rust/pull/68524#issuecomment-579566255) - resolved (https://github.com/rust-lang/rust/pull/68524#issuecomment-581144901)
* [x] Make dropck rules account for resume arguments (https://github.com/rust-lang/rust/pull/68524#issuecomment-578541137)

Follow-up work:
* Change async/await desugaring to make use of this feature
* Rewrite [`box_region.rs`](3d8778d767/src/librustc_data_structures/box_region.rs) to use resume arguments (this shows up in profiles too)
2020-02-06 22:38:33 +01:00
..
const_prop Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
inline Set mir-opt-level to 3 to prevent regressions 2020-01-15 23:41:37 +09:00
nll rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
address-of.rs Add mir opt test for AddressOf 2019-12-18 20:09:11 +00:00
array-index-is-temporary.rs Start generating AddressOf rvalues in MIR 2019-12-18 20:09:10 +00:00
basic_assignment.rs
box_expr.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
byte_slice.rs
combine_array_len.rs
const-promotion-extern-static.rs Render const pointers in MIR more compactly 2020-01-24 16:20:58 +01:00
copy_propagation_arg.rs Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01:00
copy_propagation.rs
deaggregator_test_enum_2.rs Create fewer basic blocks in match MIR lowering 2019-06-13 21:05:21 +01:00
deaggregator_test_enum.rs
deaggregator_test_multiple.rs
deaggregator_test.rs
exponential-or.rs Add more tests for or-patterns 2020-02-03 19:42:15 +00:00
generator-drop-cleanup.rs Fix miscompilation 2020-02-03 14:08:57 +01:00
generator-storage-dead-unwind.rs Adjust mir-opt tests to new yield lowering 2020-02-02 13:20:58 +01:00
graphviz.rs rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02:00
issue-38669.rs Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01:00
issue-41110.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
issue-41697.rs
issue-41888.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
issue-49232.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
issue-62289.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
loop_test.rs Only omit StorageLive/Dead for variable that are never initialized 2019-07-07 15:04:43 +01:00
match_false_edges.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
match_test.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
match-arm-scopes.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
no-spurious-drop-after-call.rs Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07:00
packed-struct-drop-aligned.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
README.md
remove_fake_borrows.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
retag.rs adjust mir-opt tests 2020-01-18 11:15:56 +01:00
retain-never-const.rs Test cleanups to match #[track_caller] in panic!. 2020-01-04 10:02:17 -08:00
return_an_array.rs
simple-match.rs Add a test for simple matches 2019-06-13 21:05:21 +01:00
simplify_cfg.rs
simplify_if.rs Create fewer basic blocks in match MIR lowering 2019-06-13 21:05:21 +01:00
simplify_match.rs Create fewer basic blocks in match MIR lowering 2019-06-13 21:05:21 +01:00
simplify_try.rs Update existing tests for or-patterns 2020-02-01 22:10:58 +00:00
simplify-arm-identity.rs SimplifyArmIdentity only for locals with the same type 2019-11-29 20:13:54 +01:00
simplify-locals-removes-unused-consts.rs Improve SimplifyLocals pass so it can remove unused consts 2019-10-20 23:49:42 -04:00
slice-drop-shim.rs adjust mir-opt tests 2020-01-18 11:15:56 +01:00
storage_live_dead_in_statics.rs Fix soundness issue with index bounds checks 2019-11-11 22:06:54 +00:00
storage_ranges.rs Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01:00
uniform_array_move_out.rs slice_patterns: remove gates in tests 2020-01-18 19:33:47 +01:00
uninhabited_enum_branching.rs Add unreachable propagation mir optimization pass 2020-01-14 08:22:10 +01:00
uninhabited-enum.rs Revert "Remove #![feature(never_type)] from tests." 2019-12-14 09:01:04 -05:00
unreachable_asm_2.rs Add unreachable propagation mir optimization pass 2020-01-14 08:22:10 +01:00
unreachable_asm.rs Add unreachable propagation mir optimization pass 2020-01-14 08:22:10 +01:00
unreachable_diverging.rs Add unreachable propagation mir optimization pass 2020-01-14 08:22:10 +01:00
unreachable.rs Add unreachable propagation mir optimization pass 2020-01-14 08:22:10 +01:00
unusual-item-types.rs adjust mir-opt tests 2020-01-18 11:15:56 +01:00
while-storage.rs Bless mir-opt/while-storage.rs. 2019-07-06 06:43:58 +02:00

This folder contains tests for MIR optimizations.

The test format is:

(arbitrary rust code)
// END RUST SOURCE
// START $file_name_of_some_mir_dump_0
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_0
// (lines or elision)
// START $file_name_of_some_mir_dump_N
//  $expected_line_0
// (lines or elision)
// $expected_line_N
// END $file_name_of_some_mir_dump_N

All the test information is in comments so the test is runnable.

For each $file_name, compiletest expects [$expected_line_0, ..., $expected_line_N] to appear in the dumped MIR in order. Currently it allows other non-matched lines before and after, but not between $expected_lines, should you want to skip lines, you must include an elision comment, of the form (as a regex) //\s*...\s*. The lines will be skipped lazily, that is, if there are two identical lines in the output that match the line after the elision comment, the first one will be matched.

Examples:

The following blocks will not match the one after it.

bb0: {
    StorageLive(_1);
    _1 = const true;
    StorageDead(_1);
}
bb0: {
    StorageLive(_1);
    _1 = const true;
    goto -> bb1
}
bb1: {
    StorageDead(_1);
    return;
}

But this will match the one above,

bb0: {
    StorageLive(_1);
    _1 = const true;
    ...
    StorageDead(_1);
    ...
}

Lines match ignoring whitespace, and the prefix "//" is removed.

It also currently strips trailing comments -- partly because the full file path in "scope comments" is unpredictable and partly because tidy complains about the lines being too long.

compiletest handles dumping the MIR before and after every pass for you. The test writer only has to specify the file names of the dumped files (not the full path to the file) and what lines to expect. There is an option to rustc that tells it to dump the mir into some directly (rather then always dumping to the current directory).