From bbd370cb25787abcacf49ec4411055a3dabfdae7 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 5 Jun 2021 22:16:40 +0200 Subject: [PATCH] Disable mutable noalias for Rust 1.53 --- compiler/rustc_codegen_llvm/src/abi.rs | 13 +++---------- src/test/codegen/function-arguments.rs | 6 +++--- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 854e3ccc21b4f..fba5667784614 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -1,7 +1,6 @@ use crate::builder::Builder; use crate::context::CodegenCx; use crate::llvm::{self, AttributePlace}; -use crate::llvm_util; use crate::type_::Type; use crate::type_of::LayoutLlvmExt; use crate::value::Value; @@ -52,15 +51,9 @@ pub trait ArgAttributesExt { } fn should_use_mutable_noalias(cx: &CodegenCx<'_, '_>) -> bool { - // LLVM prior to version 12 has known miscompiles in the presence of - // noalias attributes (see #54878). Only enable mutable noalias by - // default for versions we believe to be safe. - cx.tcx - .sess - .opts - .debugging_opts - .mutable_noalias - .unwrap_or_else(|| llvm_util::get_version() >= (12, 0, 0)) + // While #84958 has been fixed, mutable noalias is not enabled by default + // in Rust 1.53 out of an abundance of caution. + cx.tcx.sess.opts.debugging_opts.mutable_noalias.unwrap_or(false) } impl ArgAttributesExt for ArgAttributes { diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index f936f90960346..7a8646c71b7f9 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -43,13 +43,13 @@ pub fn named_borrow<'r>(_: &'r i32) { pub fn unsafe_borrow(_: &UnsafeInner) { } -// CHECK: @mutable_unsafe_borrow(i16* noalias align 2 dereferenceable(2) %_1) +// CHECK: @mutable_unsafe_borrow(i16* align 2 dereferenceable(2) %_1) // ... unless this is a mutable borrow, those never alias #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } -// CHECK: @mutable_borrow(i32* noalias align 4 dereferenceable(4) %_1) +// CHECK: @mutable_borrow(i32* align 4 dereferenceable(4) %_1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_borrow(_: &mut i32) { @@ -94,7 +94,7 @@ pub fn helper(_: usize) { pub fn slice(_: &[u8]) { } -// CHECK: @mutable_slice([0 x i8]* noalias nonnull align 1 %_1.0, [[USIZE]] %_1.1) +// CHECK: @mutable_slice([0 x i8]* nonnull align 1 %_1.0, [[USIZE]] %_1.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_slice(_: &mut [u8]) {