rust/compiler/rustc_mir_transform/src
bors e7c502d930 Auto merge of #109597 - cjgillot:gvn, r=oli-obk
Implement a global value numbering MIR optimization

The aim of this pass is to avoid repeated computations by reusing past assignments. It is based on an analysis of SSA locals, in order to perform a restricted form of common subexpression elimination.

By opportunity, this pass allows for some simplifications by combining assignments. For instance, this pass could be able to see through projections of aggregates to directly reuse the aggregate field (not in this PR).

We handle references by assigning a different "provenance" index to each `Ref`/`AddressOf` rvalue. This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we consider all the derefs of an immutable reference to a freeze type to give the same value:
```rust
_a = *_b // _b is &Freeze
_c = *_b // replaced by _c = _a
```
2023-09-27 21:06:30 +00:00
..
coverage coverage: Remove vestigial counter/expression debug labels 2023-09-20 17:24:10 +10:00
inline subst -> instantiate 2023-09-26 09:37:55 +02:00
abort_unwinding_calls.rs when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
add_call_guards.rs when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
add_moves_for_packed_drops.rs Remove DesugaringKind::Replace. 2023-05-25 17:40:46 +00:00
add_retag.rs cleanup misinformation regarding has_deref 2023-08-06 17:29:09 +03:00
check_alignment.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
check_const_item_mutation.rs Migrate mir_transform to translatable diagnostics 2023-05-02 16:24:18 +01:00
check_packed_ref.rs Migrate mir_transform to translatable diagnostics 2023-05-02 16:24:18 +01:00
check_unsafety.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
cleanup_post_borrowck.rs Actually keep PlaceMention if requested. 2023-04-21 21:34:59 +00:00
const_debuginfo.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
const_goto.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
const_prop.rs Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obk 2023-09-21 14:02:55 +00:00
const_prop_lint.rs Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obk 2023-09-21 14:02:55 +00:00
copy_prop.rs cleanup misinformation regarding has_deref 2023-08-06 17:29:09 +03:00
ctfe_limit.rs Simplify back-edge logic. 2023-05-17 12:18:55 +00:00
dataflow_const_prop.rs Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obk 2023-09-21 14:02:55 +00:00
dead_store_elimination.rs Only check packed ADT. 2023-08-24 15:42:55 +00:00
deduce_param_attrs.rs Normalize before checking if local is freeze in deduced_param_attrs 2023-08-17 14:33:24 -07:00
deduplicate_blocks.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
deref_separator.rs Avoid cloning LocalDecls. 2023-06-29 11:53:41 +10:00
dest_prop.rs when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
dump_mir.rs Write to stdout if - is given as output file 2023-06-06 17:53:29 -04:00
early_otherwise_branch.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
elaborate_box_derefs.rs refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
elaborate_drops.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
errors.rs Do not construct def_path_str for MustNotSuspend. 2023-09-23 13:14:57 +00:00
ffi_unwind_calls.rs feat: riscv-interrupt-{m,s} calling conventions 2023-08-08 18:09:56 -07:00
function_item_references.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
generator.rs Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
gvn.rs Explicit simplify_place. 2023-09-26 16:41:40 +00:00
inline.rs subst -> instantiate 2023-09-26 09:37:55 +02:00
instsimplify.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
large_enums.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
lib.rs Add global value numbering pass. 2023-09-24 09:09:04 +00:00
lower_intrinsics.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
lower_slice_len.rs Better error for non const PartialEq call generated by match 2023-06-18 05:24:38 +00:00
match_branches.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
multiple_return_terminators.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
normalize_array_len.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
nrvo.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
pass_manager.rs Generate MIR pass names for profiling on the fly and pass the body DefId as argument 2023-09-13 13:41:19 +02:00
prettify.rs make reorder BB pass use cached RPO 2023-06-14 20:08:04 +00:00
ref_prop.rs Add global value numbering pass. 2023-09-24 09:09:04 +00:00
remove_noop_landing_pads.rs when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
remove_place_mention.rs Actually keep PlaceMention if requested. 2023-04-21 21:34:59 +00:00
remove_storage_markers.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
remove_uninit_drops.rs Rename MaybeUnreachable. 2023-08-16 18:12:18 +00:00
remove_unneeded_drops.rs inline format!() args from rustc_codegen_llvm to the end (4) 2023-07-25 23:20:28 +02:00
remove_zsts.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
required_consts.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
reveal_all.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
separate_const_switch.rs when terminating during unwinding, show the reason why 2023-08-24 13:28:26 +02:00
shim.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
simplify.rs Use Vec::retain in remove_dead_blocks. 2023-09-25 17:08:40 +00:00
simplify_branches.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
simplify_comparison_integral.rs rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
sroa.rs Refactor how MIR represents composite debuginfo. 2023-09-05 17:20:07 +00:00
ssa.rs Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
uninhabited_enum_branching.rs Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
unreachable_prop.rs Skip MIR pass UnreachablePropagation when coverage is enabled 2023-09-26 20:18:43 +10:00