Skip to content
/ rust Public
forked from rust-lang/rust

Commit 7fd7d98

Browse files
authored
Rollup merge of rust-lang#159248 - workingjubilee:remove-mutable-noalias, r=Urgau
compiler: Remove `-Zmutable-noalias` Let us mark the end of an era. The `noalias` optimization has been working relatively well for some time now. There may still be issues to sort out with `noalias`. If so, those are mostly on LLVM's side, where it may need to have a better model of what `noalias` means as that is necessary for soundly inferring it. We also may need to not add `noalias` somewhere we currently do, if our semantics do not actually match that. Either way, it doesn't seem useful to configure on a compilation-wide basis.
2 parents e0828e8 + 1ccd7e1 commit 7fd7d98

7 files changed

Lines changed: 4 additions & 35 deletions

File tree

compiler/rustc_interface/src/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,6 @@ fn test_unstable_options_tracking_hash() {
852852
tracked!(mir_opt_level, Some(4));
853853
tracked!(mir_preserve_ub, true);
854854
tracked!(move_size_limit, Some(4096));
855-
tracked!(mutable_noalias, false);
856855
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
857856
tracked!(no_generate_arange_section, true);
858857
tracked!(no_link, true);

compiler/rustc_session/src/options.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,8 +2568,6 @@ options! {
25682568
"Whether to remove some of the MIR debug info from methods. Default: None"),
25692569
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
25702570
"the size at which the `large_assignments` lint starts to be emitted"),
2571-
mutable_noalias: bool = (true, parse_bool, [TRACKED],
2572-
"emit noalias metadata for mutable references (default: yes)"),
25732571
namespaced_crates: bool = (false, parse_bool, [TRACKED],
25742572
"allow crates to be namespaced by other crates (default: no)"),
25752573
next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],

compiler/rustc_ty_utils/src/abi.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,6 @@ fn arg_attrs_for_rust_scalar<'tcx>(
366366
// See https://github.com/rust-lang/unsafe-code-guidelines/issues/326
367367
let noalias_for_box = tcx.sess.opts.unstable_opts.box_noalias;
368368

369-
// LLVM prior to version 12 had known miscompiles in the presence of noalias attributes
370-
// (see #54878), so it was conditionally disabled, but we don't support earlier
371-
// versions at all anymore. We still support turning it off using -Zmutable-noalias.
372-
let noalias_mut_ref = tcx.sess.opts.unstable_opts.mutable_noalias;
373-
374369
// `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as both
375370
// `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely on memory
376371
// dependencies rather than pointer equality. However this only applies to arguments,
@@ -379,7 +374,7 @@ fn arg_attrs_for_rust_scalar<'tcx>(
379374
// `&mut T` and `Box<T>` where `T: Unpin` are unique and hence `noalias`.
380375
let no_alias = match kind {
381376
PointerKind::SharedRef { frozen } => frozen,
382-
PointerKind::MutableRef { unpin } => unpin && noalias_mut_ref,
377+
PointerKind::MutableRef { unpin } => unpin,
383378
PointerKind::Box { unpin, global } => unpin && global && noalias_for_box,
384379
};
385380
// We can never add `noalias` in return position; that LLVM attribute has some very surprising semantics

tests/codegen-llvm/noalias-flag.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/codegen-llvm/noalias-refcell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes
1+
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
44

tests/codegen-llvm/noalias-rwlockreadguard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes
1+
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes
22

33
#![crate_type = "lib"]
44

tests/codegen-llvm/noalias-unpin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags: -Copt-level=3 -Z mutable-noalias=yes
1+
//@ compile-flags: -Copt-level=3
22

33
#![crate_type = "lib"]
44

0 commit comments

Comments
 (0)