rust/src/test/mir-opt
2017-09-01 11:18:31 +03:00
..
basic_assignment.rs rustc_mir::transform::simplify - remove nops first 2017-08-01 00:12:31 +03:00
box_expr.rs emit StorageLive for box temporaries 2017-08-14 14:10:05 +03:00
copy_propagation.rs mir: Allow copy-propagation of function arguments 2016-12-11 22:12:41 +01:00
deaggregator_test.rs rustc_const_math: use apfloat::ieee::{Single,Double} in ConstFloat. 2017-08-02 17:28:11 +03:00
deaggregator_test_enum.rs update tests 2016-10-04 20:43:43 +03:00
deaggregator_test_enum_2.rs mir: Reinstate while loop in deaggregator pass 2016-12-09 18:16:38 +01:00
deaggregator_test_multiple.rs mir: Reinstate while loop in deaggregator pass 2016-12-09 18:16:38 +01:00
end_region_1.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_2.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_3.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_4.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_5.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_6.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_7.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_8.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
end_region_9.rs Leverage mir-opt to encode tests for EndRegion. 2017-06-12 13:06:42 +02:00
issue-38669.rs simplify the MirPass traits and passes dramatically 2017-05-02 14:01:01 -04:00
issue-41110.rs For box expressions, use NZ drop instead of a free block 2017-08-10 15:57:28 +03:00
issue-41697.rs remove compile-flags 2017-05-15 21:12:40 -04: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-43457.rs Regression test. 2017-08-25 16:35:42 +02:00
README.md Add tests for emitting validation statements 2017-07-30 01:11:59 -07:00
return_an_array.rs add mir optimization tests, dump-mir-dir option 2016-07-20 19:41:39 -07:00
simplify_if.rs simplify the MirPass traits and passes dramatically 2017-05-02 14:01:01 -04:00
storage_live_dead_in_statics.rs introduce local-scope to prevent storagelive/storagedead in statics 2017-05-17 07:39:57 -04:00
storage_ranges.rs make operands live to the end of their containing expression 2017-03-03 13:54:18 +02:00
validate_1.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
validate_2.rs more readable printing of validation operands 2017-07-31 15:59:29 -07:00
validate_3.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +03:00
validate_4.rs test MIR validation statements in closures 2017-08-04 17:00:21 -07:00
validate_5.rs rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent. 2017-09-01 11:18:31 +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
// ...
// $expected_line_N
// END $file_name_of_some_mir_dump_0
// ...
// START $file_name_of_some_mir_dump_N
//  $expected_line_0
// ...
// $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, after and in-between. Note that this includes lines that end basic blocks or begin new ones; it is good practice in your tests to include the terminator for each of your basic blocks as an internal sanity check guarding against a test like:

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

that will inadvertantly pattern-matching against:

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

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).