rust/compiler/rustc_mir_transform/src
Matthias Krüger 05748c66a0
Rollup merge of #107271 - Zeegomo:drop-rmw, r=oli-obk
Treat Drop as a rmw operation

Previously, a Drop terminator was considered a move in MIR. This commit changes the behavior to only treat Drop as a mutable access to the dropped place.

In order for this change to be correct, we need to guarantee that

1.  A dropped value won't be used again
   2.  Places that appear in a drop won't be used again before a
     subsequent initialization.

We can ensure this to be correct at MIR construction because Drop will only be emitted when a variable goes out of scope, thus having:
*   (1) as there is no way of reaching the old value. drop-elaboration
     will also remove any uninitialized drop.
 * (2) as the place can't be named following the end of the scope.

However, the initialization status, previously tracked by moves, should also be tied to the execution of a Drop, hence the additional logic in the dataflow analyses.

From discussion in [this thread](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/.60DROP.60.20to.20.60DROP_IF.60.20compiler-team.23558), originating from https://github.com/rust-lang/compiler-team/issues/558.
See also https://github.com/rust-lang/rust/pull/104488#discussion_r1085556010
2023-02-08 18:32:41 +01:00
..
coverage Replace enum ==s with matches where it makes sense 2023-01-30 12:26:26 +00:00
inline
abort_unwinding_calls.rs
add_call_guards.rs
add_moves_for_packed_drops.rs Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
add_retag.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
check_const_item_mutation.rs
check_packed_ref.rs make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
check_unsafety.rs Put a DefId in AggregateKind. 2023-02-02 23:09:51 +00:00
cleanup_post_borrowck.rs Remove false edges in CleanupPostBorrowck 2022-12-17 19:34:45 +01:00
const_debuginfo.rs
const_goto.rs Disable ConstGoto opt in cleanup blocks 2023-01-26 03:50:37 -08:00
const_prop_lint.rs Replace some _ == _ || _ == _s with matches!(_, _ | _)s 2023-01-30 12:26:26 +00:00
const_prop.rs Replace some _ == _ || _ == _s with matches!(_, _ | _)s 2023-01-30 12:26:26 +00:00
copy_prop.rs Comment move->copy transform. 2023-02-06 18:14:24 +01:00
ctfe_limit.rs Improve efficiency of has_back_edge(...) 2023-01-24 00:01:37 +00:00
dataflow_const_prop.rs Handle aggregates in DataflowConstProp. 2023-02-02 23:09:51 +00:00
dead_store_elimination.rs Create stable metric to measure long computation in Const Eval 2023-01-23 23:56:22 +00:00
deduce_param_attrs.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
deduplicate_blocks.rs
deref_separator.rs
dest_prop.rs Auto merge of #106908 - cjgillot:copyprop-ssa, r=oli-obk 2023-01-29 13:01:06 +00:00
dump_mir.rs Auto merge of #105220 - oli-obk:feeding, r=cjgillot 2022-12-06 03:47:41 +00:00
early_otherwise_branch.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
elaborate_box_derefs.rs Prefer doc comments over //-comments in compiler 2022-11-27 11:19:04 +00:00
elaborate_drops.rs Treat Drop as a rmw operation 2023-01-30 00:20:40 +01:00
ffi_unwind_calls.rs
function_item_references.rs fix up subst_identity vs skip_binder; add some FIXMEs as identified in review 2023-01-26 20:28:31 -07:00
generator.rs Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
inline.rs Remember where a type was kept in MIR. 2023-01-27 18:59:32 +00:00
instcombine.rs Thread a ParamEnv down to might_permit_raw_init 2023-01-23 19:25:10 -05:00
lib.rs Stop deaggegating MIR. 2023-02-02 23:20:29 +00:00
lower_intrinsics.rs
lower_slice_len.rs
match_branches.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
multiple_return_terminators.rs
normalize_array_len.rs Remove obsolete comment. 2023-01-29 22:09:51 +00:00
nrvo.rs
pass_manager.rs Use zero based indexing for pass_count 2022-12-02 15:55:24 +00:00
remove_noop_landing_pads.rs Create stable metric to measure long computation in Const Eval 2023-01-23 23:56:22 +00:00
remove_storage_markers.rs
remove_uninit_drops.rs
remove_unneeded_drops.rs
remove_zsts.rs Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
required_consts.rs
reveal_all.rs
separate_const_switch.rs Create stable metric to measure long computation in Const Eval 2023-01-23 23:56:22 +00:00
shim.rs Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simplify_branches.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
simplify_comparison_integral.rs Remove unneeded field from SwitchTargets 2022-12-09 04:53:10 -08:00
simplify.rs Auto merge of #106908 - cjgillot:copyprop-ssa, r=oli-obk 2023-01-29 13:01:06 +00:00
sroa.rs Simplify ReplacementMap. 2023-02-05 13:41:24 +00:00
ssa.rs Use successor location for dominator check. 2023-01-27 18:22:45 +00:00
uninhabited_enum_branching.rs move things from rustc_target::abi to rustc_abi 2022-11-24 16:26:13 +03:30
unreachable_prop.rs Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00