rust/tests/mir-opt
bors b583ede652 Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank
Stabilize `#![feature(target_feature_11)]`

## Stabilization report

### Summary

Allows for safe functions to be marked with `#[target_feature]` attributes.

Functions marked with `#[target_feature]` are generally considered as unsafe functions: they are unsafe to call, cannot be assigned to safe function pointers, and don't implement the `Fn*` traits.

However, calling them from other `#[target_feature]` functions with a superset of features is safe.

```rust
// Demonstration function
#[target_feature(enable = "avx2")]
fn avx2() {}

fn foo() {
    // Calling `avx2` here is unsafe, as we must ensure
    // that AVX is available first.
    unsafe {
        avx2();
    }
}

#[target_feature(enable = "avx2")]
fn bar() {
    // Calling `avx2` here is safe.
    avx2();
}
```

### Test cases

Tests for this feature can be found in [`src/test/ui/rfcs/rfc-2396-target_feature-11/`](b67ba9ba20/src/test/ui/rfcs/rfc-2396-target_feature-11/).

### Edge cases

- https://github.com/rust-lang/rust/issues/73631

Closures defined inside functions marked with `#[target_feature]` inherit the target features of their parent function. They can still be assigned to safe function pointers and implement the appropriate `Fn*` traits.

```rust
#[target_feature(enable = "avx2")]
fn qux() {
    let my_closure = || avx2(); // this call to `avx2` is safe
    let f: fn() = my_closure;
}
```

This means that in order to call a function with `#[target_feature]`, you must show that the target-feature is available while the function executes *and* for as long as whatever may escape from that function lives.

### Documentation

- Reference: https://github.com/rust-lang/reference/pull/1181

---
cc tracking issue #69098
r? `@ghost`
2023-02-28 01:14:56 +00:00
..
building Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
const_prop Remove overflow checks from ConstProp. 2023-02-18 21:35:02 +00:00
copy-prop Auto merge of #107449 - saethlin:enable-copyprop, r=oli-obk 2023-02-16 03:44:37 +00:00
dataflow-const-prop Rollup merge of #108208 - cjgillot:flood-enum, r=oli-obk 2023-02-23 06:18:06 +01:00
dead-store-elimination Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deref-patterns Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dest-prop Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inline Auto merge of #99767 - LeSeulArtichaut:stable-target-feature-11, r=estebank 2023-02-28 01:14:56 +00:00
issues Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
nll i am free 2023-01-18 04:45:43 +00:00
address_of.address_of_reborrow.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
address_of.borrow_and_cast.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
address_of.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
array_index_is_temporary.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
asm_unwind_panic_abort.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
basic_assignment.main.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
basic_assignment.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bool_compare.opt1.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bool_compare.opt2.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bool_compare.opt3.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bool_compare.opt4.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
bool_compare.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
box_expr.main.ElaborateDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
box_expr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
byte_slice.main.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
byte_slice.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
casts.redundant.InstCombine.diff Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
casts.redundant.PreCodegen.after.mir Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
casts.roundtrip.PreCodegen.after.mir Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
casts.rs Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
combine_array_len.norm2.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
combine_array_len.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff Bless tests. 2023-02-02 23:26:26 +00:00
combine_clone_of_primitives.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation2.main.ConstProp.after.32bit.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation2.main.ConstProp.after.64bit.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation3.main.ConstProp.after.32bit.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation3.main.ConstProp.after.64bit.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_allocation.main.ConstProp.after.32bit.mir Bless 32bit. 2023-02-02 23:26:34 +00:00
const_allocation.main.ConstProp.after.64bit.mir Interpret aggregates. 2023-02-02 23:09:51 +00:00
const_allocation.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_debuginfo.main.ConstDebugInfo.diff Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
const_debuginfo.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_goto_const_eval_fail.f.ConstGoto.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_goto_const_eval_fail.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_goto_storage.match_nested_if.ConstGoto.diff Bless tests. 2023-02-02 23:26:26 +00:00
const_goto_storage.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_goto.issue_77355_opt.ConstGoto.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_goto.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.BAR.PromoteTemps.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.BOP.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.FOO.PromoteTemps.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_promotion_extern_static.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
const_prop_miscompile.bar.ConstProp.diff Bless tests. 2023-02-02 23:26:26 +00:00
const_prop_miscompile.foo.ConstProp.diff Bless tests. 2023-02-02 23:26:26 +00:00
const_prop_miscompile.rs Make tests unit. 2023-01-27 18:22:44 +00:00
coverage_graphviz.bar.InstrumentCoverage.0.dot Move /src/test to /tests 2023-01-11 09:32:08 +00:00
coverage_graphviz.main.InstrumentCoverage.0.dot Move /src/test to /tests 2023-01-11 09:32:08 +00:00
coverage_graphviz.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
deduplicate_blocks.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_complex_case.main.Derefer.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_complex_case.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_inline_test.main.Derefer.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_inline_test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_terminator_test.main.Derefer.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_terminator_test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_test_multiple.main.Derefer.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_test_multiple.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_test.main.Derefer.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
derefer_test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
div_overflow.const_dividend.PreCodegen.after.mir Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
div_overflow.const_divisor.PreCodegen.after.mir Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
div_overflow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
dont_yeet_assert.generic.InstCombine.diff Make permit_uninit/zero_init fallible 2023-02-14 22:37:30 +00:00
dont_yeet_assert.rs Don't ICE in might_permit_raw_init if reference is polymorphic 2023-02-14 01:03:06 +00:00
early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_3_element_tuple.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch_68867.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_noopt.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch_soundness.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum_opt.cand.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.cand.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.invalid.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.invalid.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.rs Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.trunc.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.trunc.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.unin.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.unin.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
equal_true.opt.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
equal_true.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
exponential_or.match_tuple.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
exponential_or.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
fn_ptr_shim.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
funky_arms.float_to_exponential_common.ConstProp.diff Enable instcombine for mutable reborrows 2023-02-16 07:51:23 -05:00
funky_arms.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir Bless mir-opt tests. 2023-01-27 22:01:47 +00:00
generator_drop_cleanup.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generator_storage_dead_unwind.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
generator_tiny.main-{closure#0}.generator_resume.0.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
generator_tiny.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
graphviz.main.built.after.dot Move /src/test to /tests 2023-01-11 09:32:08 +00:00
graphviz.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.opt_char.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.opt_i8.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.opt_negative.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.opt_u32.SimplifyComparisonIntegral.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if_condition_int.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
instrument_coverage.bar.InstrumentCoverage.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
instrument_coverage.main.InstrumentCoverage.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
instrument_coverage.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
intrinsic_asserts.generic.InstCombine.diff InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
intrinsic_asserts.panics.InstCombine.diff InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
intrinsic_asserts.removable.InstCombine.diff InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
intrinsic_asserts.rs InstCombine away intrinsic validity assertions 2023-01-15 16:51:42 -05:00
issue_38669.main.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_38669.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_41110.main.ElaborateDrops.diff Emit diff instead of after mir in ElaborateDrops tests 2023-02-23 14:03:51 +01:00
issue_41110.rs Emit diff instead of after mir in ElaborateDrops tests 2023-02-23 14:03:51 +01:00
issue_41110.test.ElaborateDrops.diff ./x.py test --bless 2023-02-23 14:05:03 +01:00
issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_41697.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_41888.main.ElaborateDrops.diff ./x.py test --bless 2023-02-23 14:05:03 +01:00
issue_41888.rs Emit diff instead of after mir in ElaborateDrops tests 2023-02-23 14:03:51 +01:00
issue_62289.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_62289.test.ElaborateDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181_1.f.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181_1.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181_1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181.bar.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181.foo.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_72181.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_76432.rs Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
issue_76432.test.SimplifyComparisonIntegral.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
issue_78192.f.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_78192.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_91633.bar.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_91633.foo.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_91633.fun.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_91633.hey.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_91633.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_99325.main.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_99325.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_101973.inner.ConstProp.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
issue_101973.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
loop_test.main.SimplifyCfg-promote-consts.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
loop_test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_array_len.array_bound_mut.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_bound.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_by_value.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_raw.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_reborrow.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.rs Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_intrinsics_e2e.f_u64.PreCodegen.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics_e2e.f_unit.PreCodegen.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics_e2e.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.align_of.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.assume.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.discriminant.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff Bless tests. 2023-02-02 23:26:26 +00:00
lower_intrinsics.forget.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.non_const.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.rs Replace _with_overflow instrinsics in LowerIntrinsics. 2023-02-18 21:45:10 +00:00
lower_intrinsics.size_of.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.unreachable.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_intrinsics.with_overflow.LowerIntrinsics.diff Replace _with_overflow instrinsics in LowerIntrinsics. 2023-02-18 21:45:10 +00:00
lower_intrinsics.wrapping.LowerIntrinsics.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_slice_len.bound.LowerSliceLenCalls.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
lower_slice_len.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_arm_scopes.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_test.main.SimplifyCfg-initial.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
match_test.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
matches_reduce_branches.bar.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.foo.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
matches_u8.exhaustive_match.MatchBranchSimplification.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
matches_u8.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
multiple_return_terminators.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
multiple_return_terminators.test.MultipleReturnTerminators.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no_drop_for_inactive_variant.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no_spurious_drop_after_call.main.ElaborateDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no_spurious_drop_after_call.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
not_equal_false.opt.InstCombine.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
not_equal_false.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nrvo_simple.nrvo.RenameReturnPlace.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nrvo_simple.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
packed_struct_drop_aligned.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
README.md Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_fake_borrows.match_guard.CleanupPostBorrowck.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_fake_borrows.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_never_const.no_codegen.PreCodegen.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_never_const.rs Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
remove_storage_markers.main.RemoveStorageMarkers.diff Bless tests. 2023-02-02 23:26:26 +00:00
remove_storage_markers.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_unneeded_drops.opt.RemoveUnneededDrops.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_unneeded_drops.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
remove_zsts.get_union.PreCodegen.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
remove_zsts.get_union.RemoveZsts.diff Bless tests. 2023-02-02 23:26:26 +00:00
remove_zsts.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
retag.array_casts.SimplifyCfg-elaborate-drops.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
retag.main.SimplifyCfg-elaborate-drops.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
retag.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
return_an_array.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
separate_const_switch.identity.SeparateConstSwitch.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
separate_const_switch.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
separate_const_switch.too_complex.SeparateConstSwitch.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simple_option_map_e2e.ezmap.PreCodegen.after.mir Rollup merge of #107662 - cjgillot:copy-projection, r=oli-obk 2023-02-07 17:57:15 +01:00
simple_option_map_e2e.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_arm_identity.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_arm.id_try.SimplifyArmIdentity.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_arm.id_try.SimplifyBranchSame.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_arm.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_cfg.main.SimplifyCfg-early-opt.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_cfg.main.SimplifyCfg-initial.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_cfg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_if.main.SimplifyConstCondition-after-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_if.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
simplify_locals_fixedpoint.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff Bless tests. 2023-02-02 23:26:26 +00:00
simplify_locals_removes_unused_consts.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simplify_locals_removes_unused_discriminant_reads.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.c.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.d1.SimplifyLocals-before-const-prop.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simplify_locals.d2.SimplifyLocals-before-const-prop.diff Bless tests. 2023-02-02 23:26:26 +00:00
simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.r.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.t1.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.t2.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.t3.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_locals.t4.SimplifyLocals-before-const-prop.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_match.main.ConstProp.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
simplify_match.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
simplify_try_if_let.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice_drop_shim.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
slice_filter.rs Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00
slice_filter.variant_a-{closure#0}.CopyProp.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
slice_filter.variant_a-{closure#0}.DestinationPropagation.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
slice_filter.variant_b-{closure#0}.CopyProp.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
slice_filter.variant_b-{closure#0}.DestinationPropagation.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
spanview_block.main.built.after.html Move /src/test to /tests 2023-01-11 09:32:08 +00:00
spanview_block.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
spanview_statement.main.built.after.html Move /src/test to /tests 2023-01-11 09:32:08 +00:00
spanview_statement.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
spanview_terminator.main.built.after.html Move /src/test to /tests 2023-01-11 09:32:08 +00:00
spanview_terminator.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
sroa.constant.ScalarReplacementOfAggregates.diff Put deaggregated statements after original constant. 2023-02-09 17:27:31 +00:00
sroa.copies.ScalarReplacementOfAggregates.diff Run SROA to fixpoint. 2023-02-05 12:08:42 +00:00
sroa.dropping.ScalarReplacementOfAggregates.diff Bless tests. 2023-02-02 23:26:26 +00:00
sroa.enums.ScalarReplacementOfAggregates.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
sroa.escaping.ScalarReplacementOfAggregates.diff Clearly document intentional UB in mir-opt tests 2023-02-13 13:50:50 -05:00
sroa.flat.ScalarReplacementOfAggregates.diff Make SROA expand assignments. 2023-02-05 11:42:11 +00:00
sroa.ref_copies.ScalarReplacementOfAggregates.diff Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
sroa.rs Rollup merge of #107971 - saethlin:mir-opt-ub, r=cjgillot 2023-02-13 23:25:13 +01:00
sroa.structs.ScalarReplacementOfAggregates.diff Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
sroa.unions.ScalarReplacementOfAggregates.diff Bless tests. 2023-02-02 23:26:26 +00:00
storage_ranges.main.nll.0.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
storage_ranges.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tls_access.main.PreCodegen.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tls_access.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
try_identity_e2e.new.PreCodegen.after.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
try_identity_e2e.old.PreCodegen.after.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
try_identity_e2e.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff Bless tests. 2023-02-02 23:26:26 +00:00
uninhabited_enum_branching2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
uninhabited_enum_branching.main.UninhabitedEnumBranching.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
uninhabited_enum_branching.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_enum.process_never.SimplifyLocals-final.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_enum.process_void.SimplifyLocals-final.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_enum.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
uninhabited_fallthrough_elimination.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unreachable_diverging.main.UnreachablePropagation.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unreachable_diverging.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unreachable.main.UnreachablePropagation.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unreachable.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unusual_item_types.E-V-{constant#0}.built.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unusual_item_types.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unusual_item_types.Test-X-{constructor#0}.built.after.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
while_let_loops.change_loop_body.ConstProp.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
while_let_loops.change_loop_body.PreCodegen.after.mir Move /src/test to /tests 2023-01-11 09:32:08 +00:00
while_let_loops.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
while_storage.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
while_storage.while_loop.PreCodegen.after.mir Implement SSA CopyProp pass. 2023-01-27 18:22:45 +00:00

This folder contains tests for MIR optimizations.

The mir-opt test format emits MIR to extra files that you can automatically update by specifying --bless on the command line (just like ui tests updating .stderr files).

--blessable test format

By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the presence of pointers in constants or other bit width dependent things. In that case you can add

// EMIT_MIR_FOR_EACH_BIT_WIDTH

to your test, causing separate files to be generated for 32bit and 64bit systems.

Unit testing

If you are only testing the behavior of a particular mir-opt pass on some specific input (as is usually the case), you should add

// unit-test: PassName

to the top of the file. This makes sure that other passes don't run which means you'll get the input you expected and your test won't break when other code changes.

Emit a diff of the mir for a specific optimization

This is what you want most often when you want to see how an optimization changes the MIR.

// EMIT_MIR $file_name_of_some_mir_dump.diff

Emit mir after a specific optimization

Use this if you are just interested in the final state after an optimization.

// EMIT_MIR $file_name_of_some_mir_dump.after.mir

Emit mir before a specific optimization

This exists mainly for completeness and is rarely useful.

// EMIT_MIR $file_name_of_some_mir_dump.before.mir