rust/src/test/mir-opt
Matthew Jasper 1d7fc0ca50 Simplify MIR drop generation
Now that EndRegion is gone, we don't need to create as many gotos.
2018-11-18 12:29:44 +00:00
..
nll Update mir-opt test suite 2018-09-18 14:36:37 +02:00
array-index-is-temporary.rs array index accesses are stable places 2018-11-07 16:54:31 +01:00
basic_assignment.rs allow canonicalized regions to carry universe and track max-universe 2018-10-27 09:06:01 -04:00
box_expr.rs Update mir opt tests 2018-09-24 23:33:13 +01:00
combine_array_len.rs Update MIR opt tests 2018-06-27 22:06:21 +01:00
copy_propagation.rs Update MIR opt tests 2018-06-27 22:06:21 +01:00
copy_propagation_arg.rs Update MIR opt tests 2018-06-27 22:06:21 +01:00
deaggregator_test.rs tests: update to include move annotations in MIR. 2017-11-28 04:18:32 +02:00
deaggregator_test_enum.rs tests: update to include move annotations in MIR. 2017-11-28 04:18:32 +02:00
deaggregator_test_enum_2.rs tests: update to include move annotations in MIR. 2017-11-28 04:18:32 +02:00
deaggregator_test_multiple.rs rustc_mir: don't run the deaggregator on arrays for now. 2018-02-20 02:50:26 +02:00
inline-any-operand.rs Add test to check if inlining works for any operand 2018-09-23 16:15:46 -05:00
inline-closure-borrows-arg.rs Fix tests and rustdoc 2018-10-26 09:48:44 +13:00
inline-closure.rs Fix tests and rustdoc 2018-10-26 09:48:44 +13:00
inline-retag.rs no more action on ref or cast, but add new MIR statement for escaping a ptr to raw 2018-11-07 16:54:31 +01:00
inline-trait-method.rs [mir-inlining] Don't inline virtual calls 2018-10-14 13:45:46 -04:00
inline-trait-method_2.rs Don't inline virtual calls (take 2) 2018-11-09 22:11:40 -05:00
issue-38669.rs Update mir-opt test suite 2018-09-18 14:36:37 +02:00
issue-41110.rs rustc: use syntactic (instead of visibility) source info where appropriate. 2018-05-30 20:30:10 +03:00
issue-41697.rs fix some typos 2017-11-21 15:33:45 +01:00
issue-41888.rs move "ADT master drop flag" logic to open_drop_for_adt_contents 2017-05-28 10:43:24 +03:00
issue-49232.rs Simplify MIR drop generation 2018-11-18 12:29:44 +00:00
loop_test.rs Remove mir::StatementKind::EndRegion 2018-11-18 11:05:19 +00:00
lower_128bit_debug_test.rs Stabilize min_const_fn 2018-10-05 10:36:14 +02:00
lower_128bit_test.rs Stabilize min_const_fn 2018-10-05 10:36:14 +02:00
match_false_edges.rs Update mir opt tests 2018-09-24 23:33:13 +01:00
packed-struct-drop-aligned.rs Update tests 2018-10-26 17:27:22 +02:00
README.md fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
remove_fake_borrows.rs Add a MIR transform to remove fake reads 2018-09-24 23:33:13 +01:00
retag.rs no more action on ref or cast, but add new MIR statement for escaping a ptr to raw 2018-11-07 16:54:31 +01:00
return_an_array.rs Add trailing newlines to files which have no trailing newlines. 2017-12-30 15:50:52 +08:00
simplify_if.rs Produce instead of pointers 2018-03-08 08:08:14 +01:00
storage_live_dead_in_statics.rs Skip a shared borrow of a immutable local variables 2018-09-06 21:46:52 +01:00
storage_ranges.rs Update mir-opt test suite 2018-09-18 14:36:37 +02:00
uniform_array_move_out.rs Stabilize slice patterns without .. 2018-03-20 02:27:40 +03: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).