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;
}
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 {