rust/src/test/mir-opt
bors 5e380b797b Auto merge of #66233 - cjgillot:constkind, r=oli-obk
Split ConstValue into two enums

Hello,

Issue #59210 appeared abandoned, so I gave it a go.
Some further cleanup and refactoring may be mandated.

I did not test beyond `x.py check`, since my home computer dies compiling librustc.

Fixes #59210
2019-11-14 04:54:51 +00:00
..
const_prop Bless mir-dump test. 2019-11-12 22:02:55 +01:00
nll Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01: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 Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07: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 Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07:00
graphviz.rs rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02: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 rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02:00
inline-closure.rs rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02:00
inline-retag.rs Always emit an error for a query cycle 2019-02-15 03:51:47 +01:00
inline-trait-method.rs Print generic args in function calls in MIR 2019-05-25 10:07:01 +02:00
inline-trait-method_2.rs Print generic args in function calls in MIR 2019-05-25 10:07:01 +02:00
issue-38669.rs Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01:00
issue-41110.rs Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07: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 Use as_temp to evaluate statement expressions 2019-06-25 22:41:22 +01: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 Update tests wrt. bind_by_by_move_pattern_guards stabilization. 2019-09-08 01:39:24 +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 Re-enable Emscripten's exception handling support 2019-10-25 15:16:36 -07: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 rustc: remove "GlobalMetaData" dead code from hir::map::definitions. 2019-11-05 21:00:38 +02: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-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
slice-drop-shim.rs Improve SimplifyLocals pass so it can remove unused consts 2019-10-20 23:49:42 -04: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 Use new 'p @ ..' syntax in tests. 2019-07-28 06:53:39 +02:00
uninhabited-enum.rs Add a mir-opt test 2018-12-11 12:18:51 +00: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).