Rollup merge of #90623 - cuviper:llvm-12, r=nikic
Remove more checks for LLVM < 12 We already updated the minimum to 12 in #90175, but we missed a few `get_version()` checks.
This commit is contained in:
commit
9032b9d876
@ -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;
|
||||
@ -53,15 +52,10 @@ 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))
|
||||
// LLVM prior to version 12 had known miscompiles in the presence of
|
||||
// noalias attributes (see #54878), but we don't support earlier
|
||||
// versions at all anymore. We now enable mutable noalias by default.
|
||||
cx.tcx.sess.opts.debugging_opts.mutable_noalias.unwrap_or(true)
|
||||
}
|
||||
|
||||
impl ArgAttributesExt for ArgAttributes {
|
||||
|
@ -731,7 +731,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
}
|
||||
|
||||
fn fptoui_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
|
||||
if llvm_util::get_version() >= (12, 0, 0) && !self.fptoint_sat_broken_in_llvm() {
|
||||
if !self.fptoint_sat_broken_in_llvm() {
|
||||
let src_ty = self.cx.val_ty(val);
|
||||
let float_width = self.cx.float_width(src_ty);
|
||||
let int_width = self.cx.int_width(dest_ty);
|
||||
@ -743,7 +743,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
}
|
||||
|
||||
fn fptosi_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
|
||||
if llvm_util::get_version() >= (12, 0, 0) && !self.fptoint_sat_broken_in_llvm() {
|
||||
if !self.fptoint_sat_broken_in_llvm() {
|
||||
let src_ty = self.cx.val_ty(val);
|
||||
let float_width = self.cx.float_width(src_ty);
|
||||
let int_width = self.cx.int_width(dest_ty);
|
||||
|
@ -134,9 +134,6 @@ pub unsafe fn create_module(
|
||||
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
|
||||
|
||||
let mut target_data_layout = sess.target.data_layout.clone();
|
||||
if llvm_util::get_version() < (12, 0, 0) && sess.target.arch == "powerpc64" {
|
||||
target_data_layout = target_data_layout.replace("-v256:256:256-v512:512:512", "");
|
||||
}
|
||||
if llvm_util::get_version() < (13, 0, 0) {
|
||||
if sess.target.arch == "powerpc64" {
|
||||
target_data_layout = target_data_layout.replace("-S128", "");
|
||||
|
@ -406,11 +406,6 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
|
||||
// -Ctarget-features
|
||||
features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));
|
||||
|
||||
// FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
|
||||
if get_version() >= (12, 0, 0) && sess.target.llvm_target.contains("aarch64-unknown-linux") {
|
||||
features.push("+outline-atomics".to_string());
|
||||
}
|
||||
|
||||
features
|
||||
}
|
||||
|
||||
|
@ -3060,9 +3060,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||
// LLVM's definition of `noalias` is based solely on memory
|
||||
// dependencies rather than pointer equality
|
||||
//
|
||||
// Due to miscompiles in LLVM < 12, we apply a separate NoAliasMutRef attribute
|
||||
// for UniqueBorrowed arguments, so that the codegen backend can decide
|
||||
// whether or not to actually emit the attribute.
|
||||
// Due to past miscompiles in LLVM, we apply a separate NoAliasMutRef attribute
|
||||
// for UniqueBorrowed arguments, so that the codegen backend can decide whether
|
||||
// or not to actually emit the attribute. It can also be controlled with the
|
||||
// `-Zmutable-noalias` debugging option.
|
||||
let no_alias = match kind {
|
||||
PointerKind::Shared | PointerKind::UniqueBorrowed => false,
|
||||
PointerKind::UniqueOwned => true,
|
||||
|
@ -1193,7 +1193,7 @@ options! {
|
||||
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
|
||||
"the size at which the `large_assignments` lint starts to be emitted"),
|
||||
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"emit noalias metadata for mutable references (default: yes for LLVM >= 12, otherwise no)"),
|
||||
"emit noalias metadata for mutable references (default: yes)"),
|
||||
new_llvm_pass_manager: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||
"use new LLVM pass manager (default: no)"),
|
||||
nll_facts: bool = (false, parse_bool, [UNTRACKED],
|
||||
|
@ -68,8 +68,10 @@ mod attr_impl {
|
||||
const NonNull = 1 << 3;
|
||||
const ReadOnly = 1 << 4;
|
||||
const InReg = 1 << 5;
|
||||
// NoAlias on &mut arguments can only be used with LLVM >= 12 due to miscompiles
|
||||
// in earlier versions. FIXME: Remove this distinction once possible.
|
||||
// Due to past miscompiles in LLVM, we use a separate attribute for
|
||||
// &mut arguments, so that the codegen backend can decide whether
|
||||
// or not to actually emit the attribute. It can also be controlled
|
||||
// with the `-Zmutable-noalias` debugging option.
|
||||
const NoAliasMutRef = 1 << 6;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ pub fn target() -> Target {
|
||||
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+outline-atomics".to_string(),
|
||||
max_atomic_width: Some(128),
|
||||
mcount: "\u{1}_mcount".to_string(),
|
||||
endian: Endian::Big,
|
||||
|
@ -12,6 +12,7 @@ pub fn target() -> Target {
|
||||
arch: "aarch64".to_string(),
|
||||
options: TargetOptions {
|
||||
abi: "ilp32".to_string(),
|
||||
features: "+outline-atomics".to_string(),
|
||||
mcount: "\u{1}_mcount".to_string(),
|
||||
endian: Endian::Big,
|
||||
..base
|
||||
|
@ -7,6 +7,7 @@ pub fn target() -> Target {
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+outline-atomics".to_string(),
|
||||
mcount: "\u{1}_mcount".to_string(),
|
||||
max_atomic_width: Some(128),
|
||||
supported_sanitizers: SanitizerSet::ADDRESS
|
||||
|
@ -8,6 +8,7 @@ pub fn target() -> Target {
|
||||
arch: "aarch64".to_string(),
|
||||
options: TargetOptions {
|
||||
abi: "ilp32".to_string(),
|
||||
features: "+outline-atomics".to_string(),
|
||||
max_atomic_width: Some(128),
|
||||
mcount: "\u{1}_mcount".to_string(),
|
||||
..super::linux_gnu_base::opts()
|
||||
|
@ -9,6 +9,10 @@ pub fn target() -> Target {
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
options: TargetOptions { mcount: "\u{1}_mcount".to_string(), ..base },
|
||||
options: TargetOptions {
|
||||
features: "+outline-atomics".to_string(),
|
||||
mcount: "\u{1}_mcount".to_string(),
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user