rust/src/test/mir-opt
Manish Goregaokar e7f27947cf
Rollup merge of #60597 - wesleywiser:const_prop, r=oli-obk
Do some simple constant propagation in the ConstProp pass

r? @oli-obk

I added a few test cases. Let me know if you think there should be more.
2019-05-16 12:31:46 -07:00
..
const_prop Add test to ensure const-prop fails gracefully 2019-05-15 06:07:06 -04:00
nll Adjust mir-opt tests for new HIR without If 2019-05-10 19:41:10 +02:00
array-index-is-temporary.rs Evaluate hair::ExprKind::Use in into 2019-04-24 19:38:02 +01:00
basic_assignment.rs Remove unnecessary ignore-tidy-linelength 2019-04-23 11:42:14 +01:00
box_expr.rs rustc_mir: create the let and "remainder" scopes in source order. 2019-04-23 23:35:21 +03:00
combine_array_len.rs Remove licenses 2018-12-25 21:08:33 -07:00
copy_propagation.rs Remove licenses 2018-12-25 21:08:33 -07:00
copy_propagation_arg.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_enum.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_enum_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
deaggregator_test_multiple.rs Remove licenses 2018-12-25 21:08:33 -07:00
generator-drop-cleanup.rs Support variantful generators 2019-04-25 10:28:09 -07:00
graphviz.rs cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
inline-any-operand.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
inline-closure-borrows-arg.rs cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
inline-closure.rs cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
inline-retag.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +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 Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
issue-38669.rs Adjust mir-opt tests for new HIR without If 2019-05-10 19:41:10 +02:00
issue-41110.rs rustc_mir: create the let and "remainder" scopes in source order. 2019-04-23 23:35:21 +03:00
issue-41697.rs rustc: rename item_path to def_path (except the module in ty). 2019-03-15 13:25:10 +02:00
issue-41888.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-49232.rs rustc_mir: create the let and "remainder" scopes in source order. 2019-04-23 23:35:21 +03:00
loop_test.rs Adjust mir-opt tests for new HIR without If 2019-05-10 19:41:10 +02:00
lower_128bit_debug_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
lower_128bit_test.rs Remove licenses 2018-12-25 21:08:33 -07:00
match_false_edges.rs Fixes for shallow borrows 2019-03-31 15:14:50 +01:00
match_test.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
packed-struct-drop-aligned.rs rustc_mir: create the let and "remainder" scopes in source order. 2019-04-23 23:35:21 +03:00
README.md fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
remove_fake_borrows.rs Check which blocks are cleanup in mir-opt tests 2019-03-03 20:34:26 +00:00
retag.rs cleanup: Remove DefIndexAddressSpace 2019-05-09 00:46:38 +03:00
return_an_array.rs Remove licenses 2018-12-25 21:08:33 -07:00
simplify_cfg.rs Make SimplifyCfg collapse goto chains from bb0 2018-12-13 12:01:15 +09:00
simplify_if.rs Adjust mir-opt tests for new HIR without If 2019-05-10 19:41:10 +02:00
simplify_match.rs Run branch cleanup after copy prop 2019-03-19 12:38:18 +01:00
slice-drop-shim.rs Slightly simplify the MIR for slice drop shims 2019-05-01 19:01:57 +01:00
storage_live_dead_in_statics.rs fixing tests 2019-04-16 19:29:45 +05:30
storage_ranges.rs Fix test 2019-05-04 04:24:32 +09:00
uniform_array_move_out.rs Remove licenses 2018-12-25 21:08:33 -07:00
uninhabited-enum.rs Add a mir-opt test 2018-12-11 12:18:51 +00:00
unusual-item-types.rs Merge DefPathData::VariantCtor and DefPathData::StructCtor 2019-03-24 17:59:18 +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).