rust/src/test/mir-opt
Wesley Wiser e083273ec7 Lint overflowing integer casts in const prop
This extends the invalid cases we catch in const prop to include
overflowing integer casts using the same machinery as the overflowing
binary and unary operation logic.
2019-12-30 20:06:31 -05:00
..
const_prop Lint overflowing integer casts in const prop 2019-12-30 20:06:31 -05:00
inline Fix Instance::resolve() incorrectly returning specialized instances 2019-12-27 13:04:32 -05: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 Remove unnecessary ignore-tidy-linelength 2019-04-23 11:42:14 +01:00
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 u8 is printed as a number, not a character 2019-05-25 10:07:01 +02: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 Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01: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 Create fewer basic blocks in match MIR lowering 2019-06-13 21:05:21 +01:00
deaggregator_test_multiple.rs Remove licenses 2018-12-25 21:08:33 -07:00
generator-drop-cleanup.rs Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01:00
generator-storage-dead-unwind.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02: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 rustc: rename item_path to def_path (except the module in ty). 2019-03-15 13:25:10 +02:00
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 Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07:00
loop_test.rs Only omit StorageLive/Dead for variable that are never initialized 2019-07-07 15:04:43 +01:00
match-arm-scopes.rs rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
match_false_edges.rs Use new PromoteTemps for promotion 2019-11-08 15:00:20 -08:00
match_test.rs Add StorageDead statements for while conditions 2019-06-25 22:41:22 +01: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 fix more typos found by codespell. 2018-02-17 17:38:49 +01:00
remove_fake_borrows.rs Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07:00
retag.rs Start generating AddressOf rvalues in MIR 2019-12-18 20:09:10 +00:00
retain-never-const.rs add #![feature(never_type)] to tests as needed 2019-12-14 09:01:18 -05:00
return_an_array.rs Remove licenses 2018-12-25 21:08:33 -07:00
simple-match.rs Add a test for simple matches 2019-06-13 21:05:21 +01: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
simplify_cfg.rs Make SimplifyCfg collapse goto chains from bb0 2018-12-13 12:01:15 +09:00
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 rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. 2019-11-27 19:22:03 +02:00
slice-drop-shim.rs Make slice drop shims use AddressOf 2019-12-18 20:09:10 +00: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 Remove uniform_array_move_out passes 2019-12-09 20:43:22 +00:00
uninhabited-enum.rs Revert "Remove #![feature(never_type)] from tests." 2019-12-14 09:01:04 -05:00
uninhabited_enum_branching.rs Fix soundness issue with index bounds checks 2019-11-11 22:06:54 +00:00
unusual-item-types.rs Don't run MIR passes on constructor shims 2019-06-06 16:10:37 +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).