Rollup merge of #154297 - RalfJung:mir-opt-comments, r=dianqk

fix/extend some mir-opt comments

Looks like CopyProp was refactored without updating that comment.

And for GVN, I think this is what you had in mind @cjgillot but would be great if you could have a look.
This commit is contained in:
Jonathan Brouwer
2026-03-24 10:54:04 +01:00
committed by GitHub
2 changed files with 11 additions and 3 deletions
@@ -58,7 +58,8 @@ fn is_required(&self) -> bool {
}
}
/// Utility to help performing substitution of `*pattern` by `target`.
/// Utility to help performing substitution: for all key-value pairs in `copy_classes`,
/// all occurrences of the key get replaced by the value.
struct Replacer<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
unified: DenseBitSet<Local>,
+9 -2
View File
@@ -48,8 +48,15 @@
//! # Handling of references
//!
//! We handle references by assigning a different "provenance" index to each Ref/RawPtr 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:
//! This ensure that we do not spuriously merge borrows that should not be merged. For instance:
//! ```ignore (MIR)
//! _x = &_a;
//! _a = 0;
//! _y = &_a; // cannot be turned into `_y = _x`!
//! ```
//!
//! On top of that, we consider all the derefs of an immutable reference to a freeze type to give
//! the same value:
//! ```ignore (MIR)
//! _a = *_b // _b is &Freeze
//! _c = *_b // replaced by _c = _a