summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-18 22:50:58 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-21 20:10:54 +0100
commit39ed64399e842ec80eadb4eeb620154df6cc6130 (patch)
tree7409578d22fccd65360a653b450bd8e9ff0679b2 /compiler/rustc_codegen_llvm/src
parentc3f9403f590ac8989bc50f933541a6234e391747 (diff)
downloadrust-39ed64399e842ec80eadb4eeb620154df6cc6130.tar.gz
rust-39ed64399e842ec80eadb4eeb620154df6cc6130.zip
Enable mutable noalias by default for LLVM 12
We don't have any known noalias bugs for LLVM 12 ... yet.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/abi.rs22
1 files changed, 10 insertions, 12 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index 869c8e981f9..854e3ccc21b 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -1,6 +1,7 @@
 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;
@@ -51,18 +52,15 @@ pub trait ArgAttributesExt {
 }
 
 fn should_use_mutable_noalias(cx: &CodegenCx<'_, '_>) -> bool {
-    // Previously we would only emit noalias annotations for LLVM >= 6 or in
-    // panic=abort mode. That was deemed right, as prior versions had many bugs
-    // in conjunction with unwinding, but later versions didn’t seem to have
-    // said issues. See issue #31681.
-    //
-    // Alas, later on we encountered a case where noalias would generate wrong
-    // code altogether even with recent versions of LLVM in *safe* code with no
-    // unwinding involved. See #54462.
-    //
-    // For now, do not enable mutable_noalias by default at all, while the
-    // issue is being figured out.
-    cx.tcx.sess.opts.debugging_opts.mutable_noalias.unwrap_or(false)
+    // 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))
 }
 
 impl ArgAttributesExt for ArgAttributes {