diff --git a/Cargo.lock b/Cargo.lock index fc4c7c9888fa6..10540af220dce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3336,7 +3336,6 @@ dependencies = [ "rand 0.8.5", "rand_xoshiro", "rustc_data_structures", - "rustc_feature", "rustc_index", "rustc_macros", "rustc_serialize", @@ -3398,6 +3397,7 @@ dependencies = [ "rustc_ast_pretty", "rustc_data_structures", "rustc_errors", + "rustc_feature", "rustc_fluent_macro", "rustc_hir", "rustc_index", @@ -3702,6 +3702,7 @@ version = "0.0.0" dependencies = [ "ctrlc", "libc", + "rustc_abi", "rustc_ast", "rustc_ast_lowering", "rustc_ast_passes", @@ -4357,6 +4358,7 @@ version = "0.0.0" dependencies = [ "rustc_abi", "rustc_ast", + "rustc_ast_lowering", "rustc_ast_pretty", "rustc_attr_parsing", "rustc_data_structures", diff --git a/compiler/rustc_abi/Cargo.toml b/compiler/rustc_abi/Cargo.toml index 3acd25e546114..1013f1d3958d8 100644 --- a/compiler/rustc_abi/Cargo.toml +++ b/compiler/rustc_abi/Cargo.toml @@ -9,7 +9,6 @@ bitflags = "2.4.1" rand = { version = "0.8.4", default-features = false, optional = true } rand_xoshiro = { version = "0.6.0", optional = true } rustc_data_structures = { path = "../rustc_data_structures", optional = true } -rustc_feature = { path = "../rustc_feature", optional = true } rustc_index = { path = "../rustc_index", default-features = false } rustc_macros = { path = "../rustc_macros", optional = true } rustc_serialize = { path = "../rustc_serialize", optional = true } @@ -24,7 +23,6 @@ default = ["nightly", "randomize"] # without depending on rustc_data_structures, rustc_macros and rustc_serialize nightly = [ "dep:rustc_data_structures", - "dep:rustc_feature", "dep:rustc_macros", "dep:rustc_serialize", "dep:rustc_span", diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index daa365bf6e1d7..9fb70b80c9efb 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -1,6 +1,5 @@ #[cfg(feature = "nightly")] -use crate::{BackendRepr, FieldsShape, TyAbiInterface, TyAndLayout}; -use crate::{Primitive, Size, Variants}; +use crate::{BackendRepr, FieldsShape, Primitive, Size, TyAbiInterface, TyAndLayout, Variants}; mod reg; diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 130834d560f72..f3cf7f583cebd 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -1,7 +1,6 @@ use std::fmt; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use rustc_span::{Span, Symbol, sym}; #[cfg(test)] mod tests; @@ -95,14 +94,14 @@ impl Abi { #[derive(Copy, Clone)] pub struct AbiData { - abi: Abi, + pub abi: Abi, /// Name of this ABI as we like it called. - name: &'static str, + pub name: &'static str, } #[allow(non_upper_case_globals)] -const AbiDatas: &[AbiData] = &[ +pub const AbiDatas: &[AbiData] = &[ AbiData { abi: Abi::Rust, name: "Rust" }, AbiData { abi: Abi::C { unwind: false }, name: "C" }, AbiData { abi: Abi::C { unwind: true }, name: "C-unwind" }, @@ -142,129 +141,18 @@ const AbiDatas: &[AbiData] = &[ ]; #[derive(Copy, Clone, Debug)] -pub enum AbiUnsupported { - Unrecognized, - Reason { explain: &'static str }, -} - +pub struct AbiUnsupported {} /// Returns the ABI with the given name (if any). pub fn lookup(name: &str) -> Result { - AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi).ok_or_else(|| match name { - "riscv-interrupt" => AbiUnsupported::Reason { - explain: "please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively", - }, - "riscv-interrupt-u" => AbiUnsupported::Reason { - explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314", - }, - "wasm" => AbiUnsupported::Reason { - explain: "non-standard wasm ABI is no longer supported", - }, - - _ => AbiUnsupported::Unrecognized, - - }) -} - -pub fn all_names() -> Vec<&'static str> { - AbiDatas.iter().map(|d| d.name).collect() -} - -pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> { AbiDatas .iter() - .map(|d| d.name) - .filter(|name| is_enabled(features, span, name).is_ok()) - .collect() + .find(|abi_data| name == abi_data.name) + .map(|&x| x.abi) + .ok_or_else(|| AbiUnsupported {}) } -pub enum AbiDisabled { - Unstable { feature: Symbol, explain: &'static str }, - Unrecognized, -} - -pub fn is_enabled( - features: &rustc_feature::Features, - span: Span, - name: &str, -) -> Result<(), AbiDisabled> { - let s = is_stable(name); - if let Err(AbiDisabled::Unstable { feature, .. }) = s { - if features.enabled(feature) || span.allows_unstable(feature) { - return Ok(()); - } - } - s -} - -/// Returns whether the ABI is stable to use. -/// -/// Note that there is a separate check determining whether the ABI is even supported -/// on the current target; see `fn is_abi_supported` in `rustc_target::spec`. -pub fn is_stable(name: &str) -> Result<(), AbiDisabled> { - match name { - // Stable - "Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind" - | "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind" - | "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall" - | "thiscall-unwind" => Ok(()), - "rust-intrinsic" => Err(AbiDisabled::Unstable { - feature: sym::intrinsics, - explain: "intrinsics are subject to change", - }), - "vectorcall" => Err(AbiDisabled::Unstable { - feature: sym::abi_vectorcall, - explain: "vectorcall is experimental and subject to change", - }), - "vectorcall-unwind" => Err(AbiDisabled::Unstable { - feature: sym::abi_vectorcall, - explain: "vectorcall-unwind ABI is experimental and subject to change", - }), - "rust-call" => Err(AbiDisabled::Unstable { - feature: sym::unboxed_closures, - explain: "rust-call ABI is subject to change", - }), - "rust-cold" => Err(AbiDisabled::Unstable { - feature: sym::rust_cold_cc, - explain: "rust-cold is experimental and subject to change", - }), - "ptx-kernel" => Err(AbiDisabled::Unstable { - feature: sym::abi_ptx, - explain: "PTX ABIs are experimental and subject to change", - }), - "unadjusted" => Err(AbiDisabled::Unstable { - feature: sym::abi_unadjusted, - explain: "unadjusted ABI is an implementation detail and perma-unstable", - }), - "msp430-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_msp430_interrupt, - explain: "msp430-interrupt ABI is experimental and subject to change", - }), - "x86-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_x86_interrupt, - explain: "x86-interrupt ABI is experimental and subject to change", - }), - "gpu-kernel" => Err(AbiDisabled::Unstable { - feature: sym::abi_gpu_kernel, - explain: "gpu-kernel ABI is experimental and subject to change", - }), - "avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable { - feature: sym::abi_avr_interrupt, - explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change", - }), - "riscv-interrupt-m" | "riscv-interrupt-s" => Err(AbiDisabled::Unstable { - feature: sym::abi_riscv_interrupt, - explain: "riscv-interrupt ABIs are experimental and subject to change", - }), - "C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable { - feature: sym::abi_c_cmse_nonsecure_call, - explain: "C-cmse-nonsecure-call ABI is experimental and subject to change", - }), - "C-cmse-nonsecure-entry" => Err(AbiDisabled::Unstable { - feature: sym::cmse_nonsecure_entry, - explain: "C-cmse-nonsecure-entry ABI is experimental and subject to change", - }), - _ => Err(AbiDisabled::Unrecognized), - } +pub fn all_names() -> Vec<&'static str> { + AbiDatas.iter().map(|d| d.name).collect() } impl Abi { diff --git a/compiler/rustc_abi/src/extern_abi/tests.rs b/compiler/rustc_abi/src/extern_abi/tests.rs index 4823058dd6970..72c0f183d50c1 100644 --- a/compiler/rustc_abi/src/extern_abi/tests.rs +++ b/compiler/rustc_abi/src/extern_abi/tests.rs @@ -18,7 +18,7 @@ fn lookup_cdecl() { #[test] fn lookup_baz() { let abi = lookup("baz"); - assert_matches!(abi, Err(AbiUnsupported::Unrecognized)); + assert_matches!(abi, Err(AbiUnsupported {})); } #[test] diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index fc34b28893309..259f1c18ea8e9 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -66,9 +66,7 @@ mod extern_abi; pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind}; #[cfg(feature = "nightly")] -pub use extern_abi::{ - AbiDisabled, AbiUnsupported, ExternAbi, all_names, enabled_names, is_enabled, is_stable, lookup, -}; +pub use extern_abi::{AbiDatas, AbiUnsupported, ExternAbi, all_names, lookup}; #[cfg(feature = "nightly")] pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx}; pub use layout::{LayoutCalculator, LayoutCalculatorError}; diff --git a/compiler/rustc_ast/src/expand/autodiff_attrs.rs b/compiler/rustc_ast/src/expand/autodiff_attrs.rs index ecc522ec39d12..70222f4acabe1 100644 --- a/compiler/rustc_ast/src/expand/autodiff_attrs.rs +++ b/compiler/rustc_ast/src/expand/autodiff_attrs.rs @@ -30,14 +30,6 @@ pub enum DiffMode { Forward, /// The target function, to be created using reverse mode AD. Reverse, - /// The target function, to be created using forward mode AD. - /// This target function will also be used as a source for higher order derivatives, - /// so compute it before all Forward/Reverse targets and optimize it through llvm. - ForwardFirst, - /// The target function, to be created using reverse mode AD. - /// This target function will also be used as a source for higher order derivatives, - /// so compute it before all Forward/Reverse targets and optimize it through llvm. - ReverseFirst, } /// Dual and Duplicated (and their Only variants) are getting lowered to the same Enzyme Activity. @@ -92,10 +84,10 @@ pub struct AutoDiffAttrs { impl DiffMode { pub fn is_rev(&self) -> bool { - matches!(self, DiffMode::Reverse | DiffMode::ReverseFirst) + matches!(self, DiffMode::Reverse) } pub fn is_fwd(&self) -> bool { - matches!(self, DiffMode::Forward | DiffMode::ForwardFirst) + matches!(self, DiffMode::Forward) } } @@ -106,8 +98,6 @@ impl Display for DiffMode { DiffMode::Source => write!(f, "Source"), DiffMode::Forward => write!(f, "Forward"), DiffMode::Reverse => write!(f, "Reverse"), - DiffMode::ForwardFirst => write!(f, "ForwardFirst"), - DiffMode::ReverseFirst => write!(f, "ReverseFirst"), } } } @@ -125,12 +115,12 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool { match mode { DiffMode::Error => false, DiffMode::Source => false, - DiffMode::Forward | DiffMode::ForwardFirst => { + DiffMode::Forward => { activity == DiffActivity::Dual || activity == DiffActivity::DualOnly || activity == DiffActivity::Const } - DiffMode::Reverse | DiffMode::ReverseFirst => { + DiffMode::Reverse => { activity == DiffActivity::Const || activity == DiffActivity::Active || activity == DiffActivity::ActiveOnly @@ -166,10 +156,10 @@ pub fn valid_input_activity(mode: DiffMode, activity: DiffActivity) -> bool { return match mode { DiffMode::Error => false, DiffMode::Source => false, - DiffMode::Forward | DiffMode::ForwardFirst => { + DiffMode::Forward => { matches!(activity, Dual | DualOnly | Const) } - DiffMode::Reverse | DiffMode::ReverseFirst => { + DiffMode::Reverse => { matches!(activity, Active | ActiveOnly | Duplicated | DuplicatedOnly | Const) } }; @@ -200,8 +190,6 @@ impl FromStr for DiffMode { "Source" => Ok(DiffMode::Source), "Forward" => Ok(DiffMode::Forward), "Reverse" => Ok(DiffMode::Reverse), - "ForwardFirst" => Ok(DiffMode::ForwardFirst), - "ReverseFirst" => Ok(DiffMode::ReverseFirst), _ => Err(()), } } diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index 754f3c1a6e9ae..ce95f4dfa1b82 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -13,6 +13,7 @@ rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } +rustc_feature = { path = "../rustc_feature" } rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index f9fe4938ca8bc..d8b7cb0c3225b 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -41,13 +41,13 @@ use std::iter; use ast::visit::Visitor; use hir::def::{DefKind, PartialRes, Res}; use hir::{BodyId, HirId}; +use rustc_abi::ExternAbi; use rustc_ast::*; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; use rustc_middle::span_bug; use rustc_middle::ty::{Asyncness, ResolverAstLowering}; use rustc_span::{Ident, Span}; -use rustc_target::spec::abi; use {rustc_ast as ast, rustc_hir as hir}; use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode}; @@ -398,7 +398,7 @@ impl<'hir> LoweringContext<'_, 'hir> { safety: hir::Safety::Safe.into(), constness: hir::Constness::NotConst, asyncness: hir::IsAsync::NotAsync, - abi: abi::Abi::Rust, + abi: ExternAbi::Rust, } } diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index f727691bf479c..9f69387b7b715 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -1,5 +1,5 @@ +use rustc_errors::DiagArgFromDisplay; use rustc_errors::codes::*; -use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, Span, Symbol}; @@ -32,8 +32,6 @@ pub(crate) struct InvalidAbi { pub abi: Symbol, pub command: String, #[subdiagnostic] - pub explain: Option, - #[subdiagnostic] pub suggestion: Option, } @@ -45,19 +43,6 @@ pub(crate) struct TupleStructWithDefault { pub span: Span, } -pub(crate) struct InvalidAbiReason(pub &'static str); - -impl Subdiagnostic for InvalidAbiReason { - fn add_to_diag_with>( - self, - diag: &mut Diag<'_, G>, - _: &F, - ) { - #[allow(rustc::untranslatable_diagnostic)] - diag.note(self.0); - } -} - #[derive(Subdiagnostic)] #[suggestion( ast_lowering_invalid_abi_suggestion, diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 7379a3d2cde66..75b08e16cdbd9 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -17,9 +17,9 @@ use thin_vec::ThinVec; use tracing::instrument; use super::errors::{ - InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound, - TupleStructWithDefault, + InvalidAbi, InvalidAbiSuggestion, MisplacedRelaxTraitBound, TupleStructWithDefault, }; +use super::stability::{enabled_names, gate_unstable_abi}; use super::{ AstOwner, FnDeclKind, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode, ResolverAstLoweringExt, @@ -1479,11 +1479,16 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - pub(super) fn lower_abi(&mut self, abi: StrLit) -> ExternAbi { - rustc_abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|err| { - self.error_on_invalid_abi(abi, err); + pub(super) fn lower_abi(&mut self, abi_str: StrLit) -> ExternAbi { + let ast::StrLit { symbol_unescaped, span, .. } = abi_str; + let extern_abi = rustc_abi::lookup(symbol_unescaped.as_str()).unwrap_or_else(|_| { + self.error_on_invalid_abi(abi_str); ExternAbi::Rust - }) + }); + let sess = self.tcx.sess; + let features = self.tcx.features(); + gate_unstable_abi(sess, features, span, extern_abi); + extern_abi } pub(super) fn lower_extern(&mut self, ext: Extern) -> ExternAbi { @@ -1494,8 +1499,8 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - fn error_on_invalid_abi(&self, abi: StrLit, err: rustc_abi::AbiUnsupported) { - let abi_names = rustc_abi::enabled_names(self.tcx.features(), abi.span) + fn error_on_invalid_abi(&self, abi: StrLit) { + let abi_names = enabled_names(self.tcx.features(), abi.span) .iter() .map(|s| Symbol::intern(s)) .collect::>(); @@ -1503,10 +1508,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.dcx().emit_err(InvalidAbi { abi: abi.symbol_unescaped, span: abi.span, - explain: match err { - rustc_abi::AbiUnsupported::Reason { explain } => Some(InvalidAbiReason(explain)), - _ => None, - }, suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion { span: abi.span, suggestion: format!("\"{suggested_name}\""), diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 127b7e3684e90..3fecb9e9c7ea9 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -84,6 +84,7 @@ mod index; mod item; mod pat; mod path; +pub mod stability; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } diff --git a/compiler/rustc_ast_lowering/src/stability.rs b/compiler/rustc_ast_lowering/src/stability.rs new file mode 100644 index 0000000000000..e7c166850a46b --- /dev/null +++ b/compiler/rustc_ast_lowering/src/stability.rs @@ -0,0 +1,147 @@ +use std::fmt; + +use rustc_abi::ExternAbi; +use rustc_feature::Features; +use rustc_session::Session; +use rustc_session::parse::feature_err; +use rustc_span::symbol::sym; +use rustc_span::{Span, Symbol}; + +pub(crate) fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> { + rustc_abi::AbiDatas + .iter() + .filter(|data| extern_abi_enabled(features, span, data.abi).is_ok()) + .map(|d| d.name) + .collect() +} + +pub(crate) fn extern_abi_enabled( + features: &rustc_feature::Features, + span: Span, + abi: ExternAbi, +) -> Result<(), UnstableAbi> { + extern_abi_stability(abi).or_else(|unstable @ UnstableAbi { feature, .. }| { + if features.enabled(feature) || span.allows_unstable(feature) { + Ok(()) + } else { + Err(unstable) + } + }) +} + +#[allow(rustc::untranslatable_diagnostic)] +pub(crate) fn gate_unstable_abi(sess: &Session, features: &Features, span: Span, abi: ExternAbi) { + match extern_abi_enabled(features, span, abi) { + Ok(_) => (), + Err(unstable_abi) => { + let explain = unstable_abi.to_string(); + feature_err(sess, unstable_abi.feature, span, explain).emit(); + } + } +} + +pub struct UnstableAbi { + abi: ExternAbi, + feature: Symbol, + explain: GateReason, +} + +enum GateReason { + Experimental, + ImplDetail, +} + +impl fmt::Display for UnstableAbi { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let Self { abi, .. } = self; + let name = abi.to_string(); + let name = name.trim_matches('"'); + match self.explain { + GateReason::Experimental => { + write!(f, r#"the extern "{name}" ABI is experimental and subject to change"#) + } + GateReason::ImplDetail => { + write!( + f, + r#"the extern "{name}" ABI is an implementation detail and perma-unstable"# + ) + } + } + } +} + +pub fn extern_abi_stability(abi: ExternAbi) -> Result<(), UnstableAbi> { + match abi { + // stable ABIs + ExternAbi::Rust + | ExternAbi::C { .. } + | ExternAbi::Cdecl { .. } + | ExternAbi::Stdcall { .. } + | ExternAbi::Fastcall { .. } + | ExternAbi::Thiscall { .. } + | ExternAbi::Aapcs { .. } + | ExternAbi::Win64 { .. } + | ExternAbi::SysV64 { .. } + | ExternAbi::System { .. } + | ExternAbi::EfiApi => Ok(()), + // implementation details + ExternAbi::RustIntrinsic => { + Err(UnstableAbi { abi, feature: sym::intrinsics, explain: GateReason::ImplDetail }) + } + ExternAbi::Unadjusted => { + Err(UnstableAbi { abi, feature: sym::abi_unadjusted, explain: GateReason::ImplDetail }) + } + // experimental + ExternAbi::Vectorcall { .. } => Err(UnstableAbi { + abi, + feature: sym::abi_vectorcall, + explain: GateReason::Experimental, + }), + ExternAbi::RustCall => Err(UnstableAbi { + abi, + feature: sym::unboxed_closures, + explain: GateReason::Experimental, + }), + ExternAbi::RustCold => { + Err(UnstableAbi { abi, feature: sym::rust_cold_cc, explain: GateReason::Experimental }) + } + ExternAbi::GpuKernel => Err(UnstableAbi { + abi, + feature: sym::abi_gpu_kernel, + explain: GateReason::Experimental, + }), + ExternAbi::PtxKernel => { + Err(UnstableAbi { abi, feature: sym::abi_ptx, explain: GateReason::Experimental }) + } + ExternAbi::Msp430Interrupt => Err(UnstableAbi { + abi, + feature: sym::abi_msp430_interrupt, + explain: GateReason::Experimental, + }), + ExternAbi::X86Interrupt => Err(UnstableAbi { + abi, + feature: sym::abi_x86_interrupt, + explain: GateReason::Experimental, + }), + ExternAbi::AvrInterrupt | ExternAbi::AvrNonBlockingInterrupt => Err(UnstableAbi { + abi, + feature: sym::abi_avr_interrupt, + explain: GateReason::Experimental, + }), + ExternAbi::RiscvInterruptM | ExternAbi::RiscvInterruptS => Err(UnstableAbi { + abi, + feature: sym::abi_riscv_interrupt, + explain: GateReason::Experimental, + }), + ExternAbi::CCmseNonSecureCall => Err(UnstableAbi { + abi, + feature: sym::abi_c_cmse_nonsecure_call, + explain: GateReason::Experimental, + }), + ExternAbi::CCmseNonSecureEntry => Err(UnstableAbi { + abi, + feature: sym::cmse_nonsecure_entry, + explain: GateReason::Experimental, + }), + } +} diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 0049c5b4823cb..f9f4035cb22f0 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -20,6 +20,7 @@ use std::mem; use std::ops::{Deref, DerefMut}; use itertools::{Either, Itertools}; +use rustc_abi::ExternAbi; use rustc_ast::ptr::P; use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list}; use rustc_ast::*; @@ -35,7 +36,6 @@ use rustc_session::lint::builtin::{ }; use rustc_session::lint::{BuiltinLintDiag, LintBuffer}; use rustc_span::{Ident, Span, kw, sym}; -use rustc_target::spec::abi; use thin_vec::thin_vec; use crate::errors::{self, TildeConstReason}; @@ -723,7 +723,7 @@ impl<'a> AstValidator<'a> { MISSING_ABI, id, span, - BuiltinLintDiag::MissingAbi(span, abi::Abi::FALLBACK), + BuiltinLintDiag::MissingAbi(span, ExternAbi::FALLBACK), ) } } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 13294efdaf6f9..e5d8013058f65 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -1,9 +1,9 @@ use rustc_ast as ast; use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; use rustc_ast::{NodeId, PatKind, attr, token}; -use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue}; +use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features}; use rustc_session::Session; -use rustc_session::parse::{feature_err, feature_err_issue, feature_warn}; +use rustc_session::parse::{feature_err, feature_warn}; use rustc_span::source_map::Spanned; use rustc_span::{Span, Symbol, sym}; use thin_vec::ThinVec; @@ -72,35 +72,6 @@ struct PostExpansionVisitor<'a> { } impl<'a> PostExpansionVisitor<'a> { - #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable - fn check_abi(&self, abi: ast::StrLit) { - let ast::StrLit { symbol_unescaped, span, .. } = abi; - - match rustc_abi::is_enabled(self.features, span, symbol_unescaped.as_str()) { - Ok(()) => (), - Err(rustc_abi::AbiDisabled::Unstable { feature, explain }) => { - feature_err_issue(&self.sess, feature, span, GateIssue::Language, explain).emit(); - } - Err(rustc_abi::AbiDisabled::Unrecognized) => { - if self.sess.opts.pretty.is_none_or(|ppm| ppm.needs_hir()) { - self.sess.dcx().span_delayed_bug( - span, - format!( - "unrecognized ABI not caught in lowering: {}", - symbol_unescaped.as_str() - ), - ); - } - } - } - } - - fn check_extern(&self, ext: ast::Extern) { - if let ast::Extern::Explicit(abi, _) = ext { - self.check_abi(abi); - } - } - /// Feature gate `impl Trait` inside `type Alias = $type_expr;`. fn check_impl_trait(&self, ty: &ast::Ty, in_associated_ty: bool) { struct ImplTraitVisitor<'a> { @@ -223,12 +194,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_item(&mut self, i: &'a ast::Item) { match &i.kind { - ast::ItemKind::ForeignMod(foreign_module) => { - if let Some(abi) = foreign_module.abi { - self.check_abi(abi); - } + ast::ItemKind::ForeignMod(_foreign_module) => { + // handled during lowering } - ast::ItemKind::Struct(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Union(..) => { for attr in attr::filter_by_name(&i.attrs, sym::repr) { for item in attr.meta_item_list().unwrap_or_else(ThinVec::new) { @@ -315,7 +283,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { match &ty.kind { ast::TyKind::BareFn(bare_fn_ty) => { // Function pointers cannot be `const` - self.check_extern(bare_fn_ty.ext); self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params); } ast::TyKind::Never => { @@ -418,9 +385,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { - if let Some(header) = fn_kind.header() { + if let Some(_header) = fn_kind.header() { // Stability of const fn methods are covered in `visit_assoc_item` below. - self.check_extern(header.ext); } if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind { diff --git a/compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch index bac411d1eb03c..e3a9512dda9c6 100644 --- a/compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch +++ b/compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch @@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644 [dependencies] core = { path = "../core" } --compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std'] } -+compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std', 'no-f16-f128'] } +-compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std'] } ++compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std', 'no-f16-f128'] } [dev-dependencies] rand = { version = "0.8.5", default-features = false, features = ["alloc"] } diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 78c759bbe8c03..8bad437eeb716 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -606,10 +606,31 @@ pub(crate) fn run_pass_manager( // If this rustc version was build with enzyme/autodiff enabled, and if users applied the // `#[autodiff]` macro at least once, then we will later call llvm_optimize a second time. - let first_run = true; debug!("running llvm pm opt pipeline"); unsafe { - write::llvm_optimize(cgcx, dcx, module, config, opt_level, opt_stage, first_run)?; + write::llvm_optimize( + cgcx, + dcx, + module, + config, + opt_level, + opt_stage, + write::AutodiffStage::DuringAD, + )?; + } + // FIXME(ZuseZ4): Make this more granular + if cfg!(llvm_enzyme) && !thin { + unsafe { + write::llvm_optimize( + cgcx, + dcx, + module, + config, + opt_level, + llvm::OptStage::FatLTO, + write::AutodiffStage::PostAD, + )?; + } } debug!("lto done"); Ok(()) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 4706744f35307..ae4c4d5876e2b 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -530,6 +530,16 @@ fn get_instr_profile_output_path(config: &ModuleConfig) -> Option { config.instrument_coverage.then(|| c"default_%m_%p.profraw".to_owned()) } +// PreAD will run llvm opts but disable size increasing opts (vectorization, loop unrolling) +// DuringAD is the same as above, but also runs the enzyme opt and autodiff passes. +// PostAD will run all opts, including size increasing opts. +#[derive(Debug, Eq, PartialEq)] +pub(crate) enum AutodiffStage { + PreAD, + DuringAD, + PostAD, +} + pub(crate) unsafe fn llvm_optimize( cgcx: &CodegenContext, dcx: DiagCtxtHandle<'_>, @@ -537,7 +547,7 @@ pub(crate) unsafe fn llvm_optimize( config: &ModuleConfig, opt_level: config::OptLevel, opt_stage: llvm::OptStage, - skip_size_increasing_opts: bool, + autodiff_stage: AutodiffStage, ) -> Result<(), FatalError> { // Enzyme: // The whole point of compiler based AD is to differentiate optimized IR instead of unoptimized @@ -550,12 +560,16 @@ pub(crate) unsafe fn llvm_optimize( let unroll_loops; let vectorize_slp; let vectorize_loop; + let run_enzyme = cfg!(llvm_enzyme) && autodiff_stage == AutodiffStage::DuringAD; // When we build rustc with enzyme/autodiff support, we want to postpone size-increasing - // optimizations until after differentiation. FIXME(ZuseZ4): Before shipping on nightly, + // optimizations until after differentiation. Our pipeline is thus: (opt + enzyme), (full opt). + // We therefore have two calls to llvm_optimize, if autodiff is used. + // + // FIXME(ZuseZ4): Before shipping on nightly, // we should make this more granular, or at least check that the user has at least one autodiff // call in their code, to justify altering the compilation pipeline. - if skip_size_increasing_opts && cfg!(llvm_enzyme) { + if cfg!(llvm_enzyme) && autodiff_stage != AutodiffStage::PostAD { unroll_loops = false; vectorize_slp = false; vectorize_loop = false; @@ -565,7 +579,7 @@ pub(crate) unsafe fn llvm_optimize( vectorize_slp = config.vectorize_slp; vectorize_loop = config.vectorize_loop; } - trace!(?unroll_loops, ?vectorize_slp, ?vectorize_loop); + trace!(?unroll_loops, ?vectorize_slp, ?vectorize_loop, ?run_enzyme); let using_thin_buffers = opt_stage == llvm::OptStage::PreLinkThinLTO || config.bitcode_needed(); let pgo_gen_path = get_pgo_gen_path(config); let pgo_use_path = get_pgo_use_path(config); @@ -633,6 +647,7 @@ pub(crate) unsafe fn llvm_optimize( vectorize_loop, config.no_builtins, config.emit_lifetime_markers, + run_enzyme, sanitizer_options.as_ref(), pgo_gen_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()), pgo_use_path.as_ref().map_or(std::ptr::null(), |s| s.as_ptr()), @@ -684,18 +699,14 @@ pub(crate) unsafe fn optimize( _ => llvm::OptStage::PreLinkNoLTO, }; - // If we know that we will later run AD, then we disable vectorization and loop unrolling - let skip_size_increasing_opts = cfg!(llvm_enzyme); + // If we know that we will later run AD, then we disable vectorization and loop unrolling. + // Otherwise we pretend AD is already done and run the normal opt pipeline (=PostAD). + // FIXME(ZuseZ4): Make this more granular, only set PreAD if we actually have autodiff + // usages, not just if we build rustc with autodiff support. + let autodiff_stage = + if cfg!(llvm_enzyme) { AutodiffStage::PreAD } else { AutodiffStage::PostAD }; return unsafe { - llvm_optimize( - cgcx, - dcx, - module, - config, - opt_level, - opt_stage, - skip_size_increasing_opts, - ) + llvm_optimize(cgcx, dcx, module, config, opt_level, opt_stage, autodiff_stage) }; } Ok(()) diff --git a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs index dd5e726160d48..b2c1088e3fc02 100644 --- a/compiler/rustc_codegen_llvm/src/builder/autodiff.rs +++ b/compiler/rustc_codegen_llvm/src/builder/autodiff.rs @@ -4,10 +4,9 @@ use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, AutoDiffItem, DiffActivit use rustc_codegen_ssa::ModuleCodegen; use rustc_codegen_ssa::back::write::ModuleConfig; use rustc_errors::FatalError; -use rustc_session::config::Lto; use tracing::{debug, trace}; -use crate::back::write::{llvm_err, llvm_optimize}; +use crate::back::write::llvm_err; use crate::builder::SBuilder; use crate::context::SimpleCx; use crate::declare::declare_simple_fn; @@ -53,8 +52,6 @@ fn generate_enzyme_call<'ll>( let mut ad_name: String = match attrs.mode { DiffMode::Forward => "__enzyme_fwddiff", DiffMode::Reverse => "__enzyme_autodiff", - DiffMode::ForwardFirst => "__enzyme_fwddiff", - DiffMode::ReverseFirst => "__enzyme_autodiff", _ => panic!("logic bug in autodiff, unrecognized mode"), } .to_string(); @@ -153,7 +150,7 @@ fn generate_enzyme_call<'ll>( _ => {} } - trace!("matching autodiff arguments"); + debug!("matching autodiff arguments"); // We now handle the issue that Rust level arguments not always match the llvm-ir level // arguments. A slice, `&[f32]`, for example, is represented as a pointer and a length on // llvm-ir level. The number of activities matches the number of Rust level arguments, so we @@ -164,10 +161,10 @@ fn generate_enzyme_call<'ll>( let mut activity_pos = 0; let outer_args: Vec<&llvm::Value> = get_params(outer_fn); while activity_pos < inputs.len() { - let activity = inputs[activity_pos as usize]; + let diff_activity = inputs[activity_pos as usize]; // Duplicated arguments received a shadow argument, into which enzyme will write the // gradient. - let (activity, duplicated): (&Metadata, bool) = match activity { + let (activity, duplicated): (&Metadata, bool) = match diff_activity { DiffActivity::None => panic!("not a valid input activity"), DiffActivity::Const => (enzyme_const, false), DiffActivity::Active => (enzyme_out, false), @@ -222,7 +219,15 @@ fn generate_enzyme_call<'ll>( // A duplicated pointer will have the following two outer_fn arguments: // (..., ptr, ptr, ...). We add the following llvm-ir to our __enzyme call: // (..., metadata! enzyme_dup, ptr, ptr, ...). - assert!(llvm::LLVMRustGetTypeKind(next_outer_ty) == llvm::TypeKind::Pointer); + if matches!( + diff_activity, + DiffActivity::Duplicated | DiffActivity::DuplicatedOnly + ) { + assert!( + llvm::LLVMRustGetTypeKind(next_outer_ty) == llvm::TypeKind::Pointer + ); + } + // In the case of Dual we don't have assumptions, e.g. f32 would be valid. args.push(next_outer_arg); outer_pos += 2; activity_pos += 1; @@ -277,7 +282,7 @@ pub(crate) fn differentiate<'ll>( module: &'ll ModuleCodegen, cgcx: &CodegenContext, diff_items: Vec, - config: &ModuleConfig, + _config: &ModuleConfig, ) -> Result<(), FatalError> { for item in &diff_items { trace!("{}", item); @@ -318,29 +323,6 @@ pub(crate) fn differentiate<'ll>( // FIXME(ZuseZ4): support SanitizeHWAddress and prevent illegal/unsupported opts - if let Some(opt_level) = config.opt_level { - let opt_stage = match cgcx.lto { - Lto::Fat => llvm::OptStage::PreLinkFatLTO, - Lto::Thin | Lto::ThinLocal => llvm::OptStage::PreLinkThinLTO, - _ if cgcx.opts.cg.linker_plugin_lto.enabled() => llvm::OptStage::PreLinkThinLTO, - _ => llvm::OptStage::PreLinkNoLTO, - }; - // This is our second opt call, so now we run all opts, - // to make sure we get the best performance. - let skip_size_increasing_opts = false; - trace!("running Module Optimization after differentiation"); - unsafe { - llvm_optimize( - cgcx, - diag_handler.handle(), - module, - config, - opt_level, - opt_stage, - skip_size_increasing_opts, - )? - }; - } trace!("done with differentiate()"); Ok(()) diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 50a40c9c30927..4d6a76b23ea1a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2382,6 +2382,7 @@ unsafe extern "C" { LoopVectorize: bool, DisableSimplifyLibCalls: bool, EmitLifetimeMarkers: bool, + RunEnzyme: bool, SanitizerOptions: Option<&SanitizerOptions>, PGOGenPath: *const c_char, PGOUsePath: *const c_char, diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 7acdbd19993de..1d8f61806f56e 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -1,5 +1,6 @@ use std::str::FromStr; +use rustc_abi::ExternAbi; use rustc_ast::attr::list_contains_name; use rustc_ast::expand::autodiff_attrs::{ AutoDiffAttrs, DiffActivity, DiffMode, valid_input_activity, valid_ret_activity, @@ -23,7 +24,7 @@ use rustc_middle::ty::{self as ty, TyCtxt}; use rustc_session::parse::feature_err; use rustc_session::{Session, lint}; use rustc_span::{Ident, Span, sym}; -use rustc_target::spec::{SanitizerSet, abi}; +use rustc_target::spec::SanitizerSet; use tracing::debug; use crate::errors; @@ -219,7 +220,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { if !is_closure && let Some(fn_sig) = fn_sig() - && fn_sig.skip_binder().abi() != abi::Abi::Rust + && fn_sig.skip_binder().abi() != ExternAbi::Rust { struct_span_code_err!( tcx.dcx(), @@ -914,8 +915,6 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option { let mode = match mode.as_str() { "Forward" => DiffMode::Forward, "Reverse" => DiffMode::Reverse, - "ForwardFirst" => DiffMode::ForwardFirst, - "ReverseFirst" => DiffMode::ReverseFirst, _ => { span_bug!(mode.span, "rustc_autodiff attribute contains invalid mode"); } diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 07b88e59723d9..0b45e5786e83d 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -5,6 +5,7 @@ edition = "2021" [dependencies] # tidy-alphabetical-start +rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_lowering = { path = "../rustc_ast_lowering" } rustc_ast_passes = { path = "../rustc_ast_passes" } diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 4c47ce93dd56f..6efd11a8c3c07 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -747,7 +747,7 @@ fn print_crate_info( } } CallingConventions => { - let mut calling_conventions = rustc_target::spec::abi::all_names(); + let mut calling_conventions = rustc_abi::all_names(); calling_conventions.sort_unstable(); println_info!("{}", calling_conventions.join("\n")); } diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index d9d28299413b1..48806888b43df 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -193,6 +193,10 @@ fn main() { cfg.define(&flag, None); } + if tracked_env_var_os("LLVM_ENZYME").is_some() { + cfg.define("ENZYME", None); + } + if tracked_env_var_os("LLVM_RUSTLLVM").is_some() { cfg.define("LLVM_RUSTLLVM", None); } diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 6447a9362b3ab..a6b2384f2d7b2 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -688,14 +688,20 @@ struct LLVMRustSanitizerOptions { bool SanitizeKernelAddressRecover; }; +// This symbol won't be available or used when Enzyme is not enabled +#ifdef ENZYME +extern "C" void registerEnzyme(llvm::PassBuilder &PB); +#endif + extern "C" LLVMRustResult LLVMRustOptimize( LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef, LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage, bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR, bool LintIR, bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops, bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls, - bool EmitLifetimeMarkers, LLVMRustSanitizerOptions *SanitizerOptions, - const char *PGOGenPath, const char *PGOUsePath, bool InstrumentCoverage, + bool EmitLifetimeMarkers, bool RunEnzyme, + LLVMRustSanitizerOptions *SanitizerOptions, const char *PGOGenPath, + const char *PGOUsePath, bool InstrumentCoverage, const char *InstrProfileOutput, const char *PGOSampleUsePath, bool DebugInfoForProfiling, void *LlvmSelfProfiler, LLVMRustSelfProfileBeforePassCallback BeforePassCallback, @@ -1010,6 +1016,18 @@ extern "C" LLVMRustResult LLVMRustOptimize( MPM.addPass(NameAnonGlobalPass()); } + // now load "-enzyme" pass: +#ifdef ENZYME + if (RunEnzyme) { + registerEnzyme(PB); + if (auto Err = PB.parsePassPipeline(MPM, "enzyme")) { + std::string ErrMsg = toString(std::move(Err)); + LLVMRustSetLastError(ErrMsg.c_str()); + return LLVMRustResult::Failure; + } + } +#endif + // Upgrade all calls to old intrinsics first. for (Module::iterator I = TheModule->begin(), E = TheModule->end(); I != E;) UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 2566081cf5dba..a9b4593c13da6 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1301,9 +1301,6 @@ pub struct TyCtxt<'tcx> { gcx: &'tcx GlobalCtxt<'tcx>, } -// Explicitly implement `DynSync` and `DynSend` for `TyCtxt` to short circuit trait resolution. -unsafe impl DynSend for TyCtxt<'_> {} -unsafe impl DynSync for TyCtxt<'_> {} fn _assert_tcx_fields() { sync::assert_dyn_sync::<&'_ GlobalCtxt<'_>>(); sync::assert_dyn_send::<&'_ GlobalCtxt<'_>>(); diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index 2b8a3b9ce235c..f592a12ab75c1 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" # tidy-alphabetical-start rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } +rustc_ast_lowering = { path = "../rustc_ast_lowering" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } rustc_data_structures = { path = "../rustc_data_structures" } diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index 1e165b22e51c2..875b6edb58cbc 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -1,5 +1,6 @@ //! Checks validity of naked functions. +use rustc_abi::ExternAbi; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_hir::def_id::{LocalDefId, LocalModDefId}; @@ -11,7 +12,6 @@ use rustc_middle::span_bug; use rustc_middle::ty::TyCtxt; use rustc_session::lint::builtin::UNDEFINED_NAKED_FUNCTION_ABI; use rustc_span::{Span, sym}; -use rustc_target::spec::abi::Abi; use crate::errors::{ NakedAsmOutsideNakedFn, NakedFunctionsAsmBlock, NakedFunctionsMustNakedAsm, NoPatterns, @@ -61,8 +61,8 @@ fn check_mod_naked_functions(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { } /// Checks that function uses non-Rust ABI. -fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: Abi) { - if abi == Abi::Rust { +fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: ExternAbi) { + if abi == ExternAbi::Rust { let hir_id = tcx.local_def_id_to_hir_id(def_id); let span = tcx.def_span(def_id); tcx.emit_node_span_lint( diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 34f1ca55c7875..fd30d0d4867fe 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -4,6 +4,7 @@ use std::mem::replace; use std::num::NonZero; +use rustc_ast_lowering::stability::extern_abi_stability; use rustc_attr_parsing::{ self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER, @@ -1027,8 +1028,8 @@ impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> { if let TyKind::Never = t.kind { self.fully_stable = false; } - if let TyKind::BareFn(f) = t.kind { - if rustc_target::spec::abi::is_stable(f.abi.name()).is_err() { + if let TyKind::BareFn(function) = t.kind { + if extern_abi_stability(function.abi).is_err() { self.fully_stable = false; } } diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 50ac6c8fcde16..548fb7913650d 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -8,7 +8,7 @@ use rustc_abi::{ use rustc_macros::HashStable_Generic; use rustc_span::Symbol; -use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, WasmCAbi}; +use crate::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, RustcAbi, WasmCAbi}; mod aarch64; mod amdgpu; @@ -387,6 +387,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { /// Pass this argument directly instead. Should NOT be used! /// Only exists because of past ABI mistakes that will take time to fix /// (see ). + #[track_caller] pub fn make_direct_deprecated(&mut self) { match self.mode { PassMode::Indirect { .. } => { @@ -399,6 +400,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { /// Pass this argument indirectly, by passing a (thin or wide) pointer to the argument instead. /// This is valid for both sized and unsized arguments. + #[track_caller] pub fn make_indirect(&mut self) { match self.mode { PassMode::Direct(_) | PassMode::Pair(_, _) => { @@ -413,6 +415,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { /// Same as `make_indirect`, but for arguments that are ignored. Only needed for ABIs that pass /// ZSTs indirectly. + #[track_caller] pub fn make_indirect_from_ignore(&mut self) { match self.mode { PassMode::Ignore => { @@ -736,7 +739,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { C: HasDataLayout + HasTargetSpec, { let spec = cx.target_spec(); - match &spec.arch[..] { + match &*spec.arch { "x86" => x86::compute_rust_abi_info(cx, self, abi), "riscv32" | "riscv64" => riscv::compute_rust_abi_info(cx, self, abi), "loongarch64" => loongarch::compute_rust_abi_info(cx, self, abi), @@ -744,6 +747,22 @@ impl<'a, Ty> FnAbi<'a, Ty> { _ => {} }; + // Decides whether we can pass the given SIMD argument via `PassMode::Direct`. + // May only return `true` if the target will always pass those arguments the same way, + // no matter what the user does with `-Ctarget-feature`! In other words, whatever + // target features are required to pass a SIMD value in registers must be listed in + // the `abi_required_features` for the current target and ABI. + let can_pass_simd_directly = |arg: &ArgAbi<'_, Ty>| match &*spec.arch { + // On x86, if we have SSE2 (which we have by default for x86_64), we can always pass up + // to 128-bit-sized vectors. + "x86" if spec.rustc_abi == Some(RustcAbi::X86Sse2) => arg.layout.size.bits() <= 128, + "x86_64" if spec.rustc_abi != Some(RustcAbi::X86Softfloat) => { + arg.layout.size.bits() <= 128 + } + // So far, we haven't implemented this logic for any other target. + _ => false, + }; + for (arg_idx, arg) in self .args .iter_mut() @@ -751,12 +770,15 @@ impl<'a, Ty> FnAbi<'a, Ty> { .map(|(idx, arg)| (Some(idx), arg)) .chain(iter::once((None, &mut self.ret))) { - if arg.is_ignore() { + // If the logic above already picked a specific type to cast the argument to, leave that + // in place. + if matches!(arg.mode, PassMode::Ignore | PassMode::Cast { .. }) { continue; } if arg_idx.is_none() && arg.layout.size > Primitive::Pointer(AddressSpace::DATA).size(cx) * 2 + && !matches!(arg.layout.backend_repr, BackendRepr::Vector { .. }) { // Return values larger than 2 registers using a return area // pointer. LLVM and Cranelift disagree about how to return @@ -766,7 +788,8 @@ impl<'a, Ty> FnAbi<'a, Ty> { // return value independently and decide to pass it in a // register or not, which would result in the return value // being passed partially in registers and partially through a - // return area pointer. + // return area pointer. For large IR-level values such as `i128`, + // cranelift will even split up the value into smaller chunks. // // While Cranelift may need to be fixed as the LLVM behavior is // generally more correct with respect to the surface language, @@ -796,53 +819,60 @@ impl<'a, Ty> FnAbi<'a, Ty> { // rustc_target already ensure any return value which doesn't // fit in the available amount of return registers is passed in // the right way for the current target. + // + // The adjustment is not necessary nor desired for types with a vector + // representation; those are handled below. arg.make_indirect(); continue; } match arg.layout.backend_repr { - BackendRepr::Memory { .. } => {} - - // This is a fun case! The gist of what this is doing is - // that we want callers and callees to always agree on the - // ABI of how they pass SIMD arguments. If we were to *not* - // make these arguments indirect then they'd be immediates - // in LLVM, which means that they'd used whatever the - // appropriate ABI is for the callee and the caller. That - // means, for example, if the caller doesn't have AVX - // enabled but the callee does, then passing an AVX argument - // across this boundary would cause corrupt data to show up. - // - // This problem is fixed by unconditionally passing SIMD - // arguments through memory between callers and callees - // which should get them all to agree on ABI regardless of - // target feature sets. Some more information about this - // issue can be found in #44367. - // - // Note that the intrinsic ABI is exempt here as - // that's how we connect up to LLVM and it's unstable - // anyway, we control all calls to it in libstd. - BackendRepr::Vector { .. } - if abi != ExternAbi::RustIntrinsic && spec.simd_types_indirect => - { - arg.make_indirect(); - continue; + BackendRepr::Memory { .. } => { + // Compute `Aggregate` ABI. + + let is_indirect_not_on_stack = + matches!(arg.mode, PassMode::Indirect { on_stack: false, .. }); + assert!(is_indirect_not_on_stack); + + let size = arg.layout.size; + if arg.layout.is_sized() + && size <= Primitive::Pointer(AddressSpace::DATA).size(cx) + { + // We want to pass small aggregates as immediates, but using + // an LLVM aggregate type for this leads to bad optimizations, + // so we pick an appropriately sized integer type instead. + arg.cast_to(Reg { kind: RegKind::Integer, size }); + } } - _ => continue, - } - // Compute `Aggregate` ABI. - - let is_indirect_not_on_stack = - matches!(arg.mode, PassMode::Indirect { on_stack: false, .. }); - assert!(is_indirect_not_on_stack); - - let size = arg.layout.size; - if !arg.layout.is_unsized() && size <= Primitive::Pointer(AddressSpace::DATA).size(cx) { - // We want to pass small aggregates as immediates, but using - // an LLVM aggregate type for this leads to bad optimizations, - // so we pick an appropriately sized integer type instead. - arg.cast_to(Reg { kind: RegKind::Integer, size }); + BackendRepr::Vector { .. } => { + // This is a fun case! The gist of what this is doing is + // that we want callers and callees to always agree on the + // ABI of how they pass SIMD arguments. If we were to *not* + // make these arguments indirect then they'd be immediates + // in LLVM, which means that they'd used whatever the + // appropriate ABI is for the callee and the caller. That + // means, for example, if the caller doesn't have AVX + // enabled but the callee does, then passing an AVX argument + // across this boundary would cause corrupt data to show up. + // + // This problem is fixed by unconditionally passing SIMD + // arguments through memory between callers and callees + // which should get them all to agree on ABI regardless of + // target feature sets. Some more information about this + // issue can be found in #44367. + // + // Note that the intrinsic ABI is exempt here as those are not + // real functions anyway, and the backend expects very specific types. + if abi != ExternAbi::RustIntrinsic + && spec.simd_types_indirect + && !can_pass_simd_directly(arg) + { + arg.make_indirect(); + } + } + + _ => {} } } } diff --git a/compiler/rustc_target/src/callconv/x86.rs b/compiler/rustc_target/src/callconv/x86.rs index 5b9414536d8ca..5f4f4cd57f654 100644 --- a/compiler/rustc_target/src/callconv/x86.rs +++ b/compiler/rustc_target/src/callconv/x86.rs @@ -4,7 +4,7 @@ use rustc_abi::{ }; use crate::callconv::{ArgAttribute, FnAbi, PassMode}; -use crate::spec::HasTargetSpec; +use crate::spec::{HasTargetSpec, RustcAbi}; #[derive(PartialEq)] pub(crate) enum Flavor { @@ -236,8 +236,16 @@ where _ => false, // anyway not passed via registers on x86 }; if has_float { - if fn_abi.ret.layout.size <= Primitive::Pointer(AddressSpace::DATA).size(cx) { - // Same size or smaller than pointer, return in a register. + if cx.target_spec().rustc_abi == Some(RustcAbi::X86Sse2) + && fn_abi.ret.layout.backend_repr.is_scalar() + && fn_abi.ret.layout.size.bits() <= 128 + { + // This is a single scalar that fits into an SSE register, and the target uses the + // SSE ABI. We prefer this over integer registers as float scalars need to be in SSE + // registers for float operations, so that's the best place to pass them around. + fn_abi.ret.cast_to(Reg { kind: RegKind::Vector, size: fn_abi.ret.layout.size }); + } else if fn_abi.ret.layout.size <= Primitive::Pointer(AddressSpace::DATA).size(cx) { + // Same size or smaller than pointer, return in an integer register. fn_abi.ret.cast_to(Reg { kind: RegKind::Integer, size: fn_abi.ret.layout.size }); } else { // Larger than a pointer, return indirectly. diff --git a/compiler/rustc_target/src/spec/base/apple/mod.rs b/compiler/rustc_target/src/spec/base/apple/mod.rs index 497994a5998cb..1b56143545f61 100644 --- a/compiler/rustc_target/src/spec/base/apple/mod.rs +++ b/compiler/rustc_target/src/spec/base/apple/mod.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use std::env; use crate::spec::{ - Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, SplitDebuginfo, StackProbeType, - StaticCow, TargetOptions, cvs, + Cc, DebuginfoKind, FloatAbi, FramePointer, LinkerFlavor, Lld, RustcAbi, SplitDebuginfo, + StackProbeType, StaticCow, TargetOptions, cvs, }; #[cfg(test)] @@ -103,7 +103,7 @@ pub(crate) fn base( arch: Arch, abi: TargetAbi, ) -> (TargetOptions, StaticCow, StaticCow) { - let opts = TargetOptions { + let mut opts = TargetOptions { abi: abi.target_abi().into(), llvm_floatabi: Some(FloatAbi::Hard), os: os.into(), @@ -154,6 +154,10 @@ pub(crate) fn base( ..Default::default() }; + if matches!(arch, Arch::I386 | Arch::I686) { + // All Apple x86-32 targets have SSE2. + opts.rustc_abi = Some(RustcAbi::X86Sse2); + } (opts, unversioned_llvm_target(os, arch, abi), arch.target_arch()) } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index df1862ec27eee..b2aedec1eebb9 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -57,13 +57,6 @@ use crate::spec::crt_objects::CrtObjects; pub mod crt_objects; -pub mod abi { - pub use rustc_abi::{ - AbiDisabled, AbiUnsupported, ExternAbi as Abi, all_names, enabled_names, is_enabled, - is_stable, lookup, - }; -} - mod base; mod json; @@ -1116,6 +1109,8 @@ impl ToJson for FloatAbi { /// The Rustc-specific variant of the ABI used for this target. #[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum RustcAbi { + /// On x86-32 only: make use of SSE and SSE2 for ABI purposes. + X86Sse2, /// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI. X86Softfloat, } @@ -1125,6 +1120,7 @@ impl FromStr for RustcAbi { fn from_str(s: &str) -> Result { Ok(match s { + "x86-sse2" => RustcAbi::X86Sse2, "x86-softfloat" => RustcAbi::X86Softfloat, _ => return Err(()), }) @@ -1134,6 +1130,7 @@ impl FromStr for RustcAbi { impl ToJson for RustcAbi { fn to_json(&self) -> Json { match *self { + RustcAbi::X86Sse2 => "x86-sse2", RustcAbi::X86Softfloat => "x86-softfloat", } .to_json() @@ -3270,6 +3267,11 @@ impl Target { // Check consistency of Rust ABI declaration. if let Some(rust_abi) = self.rustc_abi { match rust_abi { + RustcAbi::X86Sse2 => check_matches!( + &*self.arch, + "x86", + "`x86-sse2` ABI is only valid for x86-32 targets" + ), RustcAbi::X86Softfloat => check_matches!( &*self.arch, "x86" | "x86_64", diff --git a/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs b/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs index fa21cfbab8a3c..6a98a763b364d 100644 --- a/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs +++ b/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs @@ -1,5 +1,5 @@ use crate::spec::base::nto_qnx; -use crate::spec::{StackProbeType, Target, TargetOptions, base}; +use crate::spec::{RustcAbi, StackProbeType, Target, TargetOptions, base}; pub(crate) fn target() -> Target { let mut meta = nto_qnx::meta(); @@ -14,6 +14,7 @@ pub(crate) fn target() -> Target { .into(), arch: "x86".into(), options: TargetOptions { + rustc_abi: Some(RustcAbi::X86Sse2), cpu: "pentium4".into(), max_atomic_width: Some(64), pre_link_args: nto_qnx::pre_link_args( diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs index e481e967ebfa2..f04e3c2c2a5b0 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_gnu.rs @@ -2,6 +2,7 @@ use crate::spec::Target; pub(crate) fn target() -> Target { let mut base = super::i686_unknown_linux_gnu::target(); + base.rustc_abi = None; // overwrite the SSE2 ABI set by the base target base.cpu = "pentium".into(); base.llvm_target = "i586-unknown-linux-gnu".into(); base diff --git a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs index 8ad93496f3a8c..42babb90da7cc 100644 --- a/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/i586_unknown_linux_musl.rs @@ -2,6 +2,7 @@ use crate::spec::Target; pub(crate) fn target() -> Target { let mut base = super::i686_unknown_linux_musl::target(); + base.rustc_abi = None; // overwrite the SSE2 ABI set by the base target base.cpu = "pentium".into(); base.llvm_target = "i586-unknown-linux-musl".into(); // FIXME(compiler-team#422): musl targets should be dynamically linked by default. diff --git a/compiler/rustc_target/src/spec/targets/i686_linux_android.rs b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs index dcf9b6b4460f3..4744ca859dfe0 100644 --- a/compiler/rustc_target/src/spec/targets/i686_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/i686_linux_android.rs @@ -1,4 +1,4 @@ -use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions, base}; +use crate::spec::{RustcAbi, SanitizerSet, StackProbeType, Target, TargetOptions, base}; // See https://developer.android.com/ndk/guides/abis.html#x86 // for target ABI requirements. @@ -8,6 +8,7 @@ pub(crate) fn target() -> Target { base.max_atomic_width = Some(64); + base.rustc_abi = Some(RustcAbi::X86Sse2); // https://developer.android.com/ndk/guides/abis.html#x86 base.cpu = "pentiumpro".into(); base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into(); diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs index 208fe50912ca9..06dbf1e3a1657 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs index 5df8dce1aa352..05d848e039315 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces diff --git a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs index 180750bc7a8b2..e0e471130874c 100644 --- a/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_windows_msvc.rs @@ -1,7 +1,8 @@ -use crate::spec::{LinkerFlavor, Lld, SanitizerSet, Target, base}; +use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS; diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs index 85ab87cc07f77..71c26041a50a4 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::freebsd::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]); diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs index 1ab493c787c2a..464ac46b07c0e 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::haiku::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs index c95cb308d7f5c..fe699dbcb5109 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs @@ -1,7 +1,19 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, SanitizerSet, StackProbeType, Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, SanitizerSet, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::linux_gnu::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); + // Dear distribution packager, if you are changing the base CPU model with the goal of removing + // the SSE2 requirement, make sure to also set the `rustc_abi` to `None` above or else the compiler + // will complain that the chosen ABI cannot be realized with the given CPU features. + // Also note that x86 without SSE2 is *not* considered a Tier 1 target by the Rust project, and + // it has some known floating-point correctness issues mostly caused by a lack of people caring + // for LLVM's x87 support (double-rounding, value truncation; see + // for details). This can lead to incorrect + // math (Rust generally promises exact math, so this can break code in unexpected ways) and it + // can lead to memory safety violations if floating-point values are used e.g. to access an + // array. If users run into such issues and report bugs upstream and then it turns out that the + // bugs are caused by distribution patches, that leads to confusion and frustration. base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS; diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs index 6ba87c732b72d..3d25c951e813f 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs @@ -1,7 +1,10 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::linux_musl::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); + // If you want to change the base CPU, please see `i686_unknown_linux_gnu.rs` + // for an important comment. base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]); diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs index 092ba5c7baa16..4bc6eee1ac272 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, TargetOptions, base}; pub(crate) fn target() -> Target { let mut base = base::netbsd::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs index 7ae9189e23393..a3bdf66a14d89 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::openbsd::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]); diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs index 6e3733538edf1..0e1b65ef598c0 100644 --- a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_gnu.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_gnu::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces diff --git a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs index e0de9b9af45f2..44cf9b1adda14 100644 --- a/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_uwp_windows_msvc.rs @@ -1,7 +1,8 @@ -use crate::spec::{Target, base}; +use crate::spec::{RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_uwp_msvc::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); diff --git a/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs index 1d084c0729cc1..e9100da14cba2 100644 --- a/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/i686_win7_windows_gnu.rs @@ -1,8 +1,9 @@ -use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, Target, base}; +use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); base.vendor = "win7".into(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.frame_pointer = FramePointer::Always; // Required for backtraces diff --git a/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs index 7efba3aa986ab..94284a2fe72b2 100644 --- a/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs @@ -1,8 +1,9 @@ -use crate::spec::{LinkerFlavor, Lld, SanitizerSet, Target, base}; +use crate::spec::{LinkerFlavor, Lld, RustcAbi, SanitizerSet, Target, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); base.vendor = "win7".into(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.supported_sanitizers = SanitizerSet::ADDRESS; diff --git a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs index dfffa6e138f85..4e801955d0cb1 100644 --- a/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs +++ b/compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs @@ -1,7 +1,8 @@ -use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base}; +use crate::spec::{Cc, LinkerFlavor, Lld, RustcAbi, StackProbeType, Target, base}; pub(crate) fn target() -> Target { let mut base = base::vxworks::opts(); + base.rustc_abi = Some(RustcAbi::X86Sse2); base.cpu = "pentium4".into(); base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index ea7c15a359538..96b2fc8af70ea 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -789,6 +789,13 @@ impl Target { // x87 must be enabled, soft-float must be disabled. FeatureConstraints { required: &["x87"], incompatible: &["soft-float"] } } + Some(RustcAbi::X86Sse2) => { + // Extended hardfloat ABI. x87 and SSE2 must be enabled, soft-float must be disabled. + FeatureConstraints { + required: &["x87", "sse2"], + incompatible: &["soft-float"], + } + } Some(RustcAbi::X86Softfloat) => { // Softfloat ABI, requires corresponding target feature. That feature trumps // `x87` and all other FPU features so those do not matter. @@ -816,6 +823,7 @@ impl Target { // LLVM handles the rest. FeatureConstraints { required: &["soft-float"], incompatible: &[] } } + Some(r) => panic!("invalid Rust ABI for x86_64: {r:?}"), } } "arm" => { diff --git a/library/Cargo.lock b/library/Cargo.lock index 8b78908e6d730..930db2ecd5796 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.145" +version = "0.1.146" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0705f5abaaab7168ccc14f8f340ded61be2bd3ebea86b9834b6acbc8495de8" +checksum = "a97117b1434b79833f39a5fabdf82f890bd98c1988334dea1cb67f7e627fa311" dependencies = [ "cc", "rustc-std-workspace-core", diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index db7eaf52fb227..6b0b5761391c7 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" [dependencies] core = { path = "../core" } -compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std'] } +compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std'] } [dev-dependencies] rand = { version = "0.8.5", default-features = false, features = ["alloc"] } diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index aa391a4b317ac..add5a20d179a0 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core", public = true } -compiler_builtins = { version = "=0.1.145" } +compiler_builtins = { version = "=0.1.146" } unwind = { path = "../unwind" } hashbrown = { version = "0.15", default-features = false, features = [ 'rustc-dep-of-std', diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index cd3558ac6a49b..d22fad1840635 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1049,12 +1049,12 @@ pub fn rustc_cargo( // . cargo.rustflag("-Zon-broken-pipe=kill"); - // We temporarily disable linking here as part of some refactoring. - // This way, people can manually use -Z llvm-plugins and -C passes=enzyme for now. - // In a follow-up PR, we will re-enable linking here and load the pass for them. - //if builder.config.llvm_enzyme { - // cargo.rustflag("-l").rustflag("Enzyme-19"); - //} + // We want to link against registerEnzyme and in the future we want to use additional + // functionality from Enzyme core. For that we need to link against Enzyme. + // FIXME(ZuseZ4): Get the LLVM version number automatically instead of hardcoding it. + if builder.config.llvm_enzyme { + cargo.rustflag("-l").rustflag("Enzyme-19"); + } // Building with protected visibility reduces the number of dynamic relocations needed, giving // us a faster startup time. However GNU ld < 2.40 will error if we try to link a shared object @@ -1234,6 +1234,9 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect if builder.is_rust_llvm(target) { cargo.env("LLVM_RUSTLLVM", "1"); } + if builder.config.llvm_enzyme { + cargo.env("LLVM_ENZYME", "1"); + } let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target }); cargo.env("LLVM_CONFIG", &llvm_config); diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 49bf04356d5bc..46b98a8e7babe 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -968,6 +968,7 @@ impl Step for Enzyme { .env("LLVM_CONFIG_REAL", &llvm_config) .define("LLVM_ENABLE_ASSERTIONS", "ON") .define("ENZYME_EXTERNAL_SHARED_LIB", "ON") + .define("ENZYME_RUNPASS", "ON") .define("LLVM_DIR", builder.llvm_out(target)); cfg.build(); diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile index 71eb72686b06a..e3f23149284e5 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-linux/Dockerfile @@ -3,8 +3,8 @@ FROM ubuntu:22.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh -COPY scripts/crosstool-ng-git.sh /scripts/ -RUN sh /scripts/crosstool-ng-git.sh +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh COPY scripts/rustbuild-setup.sh /scripts/ RUN sh /scripts/rustbuild-setup.sh diff --git a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile index 5081f25e56743..2c33b5526eebc 100644 --- a/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile @@ -3,8 +3,8 @@ FROM ubuntu:22.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh -COPY scripts/crosstool-ng-git.sh /scripts/ -RUN sh /scripts/crosstool-ng-git.sh +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh COPY scripts/rustbuild-setup.sh /scripts/ RUN sh /scripts/rustbuild-setup.sh diff --git a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile index 9d3be51d037d1..cb20f43cff706 100644 --- a/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-powerpc64le-linux/Dockerfile @@ -3,8 +3,8 @@ FROM ubuntu:22.04 COPY scripts/cross-apt-packages.sh /scripts/ RUN sh /scripts/cross-apt-packages.sh -COPY scripts/crosstool-ng-git.sh /scripts/ -RUN sh /scripts/crosstool-ng-git.sh +COPY scripts/crosstool-ng.sh /scripts/ +RUN sh /scripts/crosstool-ng.sh COPY scripts/rustbuild-setup.sh /scripts/ RUN sh /scripts/rustbuild-setup.sh diff --git a/src/ci/docker/scripts/crosstool-ng-git.sh b/src/ci/docker/scripts/crosstool-ng-git.sh deleted file mode 100644 index e86810ae6133e..0000000000000 --- a/src/ci/docker/scripts/crosstool-ng-git.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -ex - -URL=https://github.com/crosstool-ng/crosstool-ng -REV=ed12fa68402f58e171a6f79500f73f4781fdc9e5 - -mkdir crosstool-ng -cd crosstool-ng -git init -git fetch --depth=1 ${URL} ${REV} -git reset --hard FETCH_HEAD -./bootstrap -./configure --prefix=/usr/local -make -j$(nproc) -make install -cd .. -rm -rf crosstool-ng diff --git a/src/ci/docker/scripts/crosstool-ng.sh b/src/ci/docker/scripts/crosstool-ng.sh index c3ee19b8d2c1f..eee912b0d750d 100644 --- a/src/ci/docker/scripts/crosstool-ng.sh +++ b/src/ci/docker/scripts/crosstool-ng.sh @@ -1,7 +1,7 @@ #!/bin/sh set -ex -CT_NG=1.26.0 +CT_NG=1.27.0 url="https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-$CT_NG.tar.gz" curl -Lf $url | tar xzf - diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 341d82599fd07..6b5767060a2e9 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -452,26 +452,26 @@ auto: - name: x86_64-msvc-1 env: - RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler + RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-sanitizers --enable-profiler SCRIPT: make ci-msvc-py <<: *job-windows-25 - name: x86_64-msvc-2 env: - RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler + RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-sanitizers --enable-profiler SCRIPT: make ci-msvc-ps1 <<: *job-windows-25 # i686-msvc is split into two jobs to run tests in parallel. - name: i686-msvc-1 env: - RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc + RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc --enable-sanitizers SCRIPT: make ci-msvc-py <<: *job-windows - name: i686-msvc-2 env: - RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc + RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc --enable-sanitizers SCRIPT: make ci-msvc-ps1 <<: *job-windows diff --git a/src/tools/enzyme b/src/tools/enzyme index 0e5fa4a3d475f..7f3b207c4413c 160000 --- a/src/tools/enzyme +++ b/src/tools/enzyme @@ -1 +1 @@ -Subproject commit 0e5fa4a3d475f4dece489c9e06b11164f83789f5 +Subproject commit 7f3b207c4413c9d715fd54b36b8a8fd3179e0b67 diff --git a/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr new file mode 100644 index 0000000000000..171bf0c82d511 --- /dev/null +++ b/src/tools/miri/tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.stderr @@ -0,0 +1,5 @@ +warning: target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + diff --git a/tests/assembly/closure-inherit-target-feature.rs b/tests/assembly/closure-inherit-target-feature.rs index 4692653d91fc6..9f73820f0ea1f 100644 --- a/tests/assembly/closure-inherit-target-feature.rs +++ b/tests/assembly/closure-inherit-target-feature.rs @@ -15,9 +15,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 { // check that _mm_blend_ps is not being inlined into the closure // CHECK-LABEL: {{sse41_blend_nofeature.*closure.*:}} // CHECK-NOT: blendps - // CHECK: {{call .*_mm_blend_ps.*}} + // CHECK: {{jmp .*_mm_blend_ps.*}} // CHECK-NOT: blendps - // CHECK: ret #[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101) }; diff --git a/tests/assembly/indexing-with-bools-no-redundant-instructions.rs b/tests/assembly/indexing-with-bools-no-redundant-instructions.rs new file mode 100644 index 0000000000000..af85033b4744a --- /dev/null +++ b/tests/assembly/indexing-with-bools-no-redundant-instructions.rs @@ -0,0 +1,31 @@ +//@ assembly-output: emit-asm +//@ only-x86_64 +//@ ignore-sgx Test incompatible with LVI mitigations +//@ compile-flags: -C opt-level=3 +//! Ensure that indexing a slice with `bool` does not +//! generate any redundant `jmp` and `and` instructions. +//! Discovered in issue #123216. + +#![crate_type = "lib"] + +#[no_mangle] +fn f(a: u32, b: bool, c: bool, d: &mut [u128; 2]) { + // CHECK-LABEL: f: + // CHECK: testl %esi, %esi + // CHECK: je + // CHECK: xorb %dl, %dil + // CHECK: orb $1, (%rcx) + // CHECK: movzbl %dil, %eax + // CHECK: andl $1, %eax + // CHECK: shll $4, %eax + // CHECK: orb $1, (%rcx,%rax) + // CHECK-NOT: jmp + // CHECK-NOT: andl %dil, $1 + // CHECK: retq + let mut a = a & 1 != 0; + if b { + a ^= c; + d[0] |= 1; + } + d[a as usize] |= 1; +} diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs index acd1af8d38af1..0802116bf61d1 100644 --- a/tests/assembly/x86-return-float.rs +++ b/tests/assembly/x86-return-float.rs @@ -1,19 +1,31 @@ //@ assembly-output: emit-asm -//@ only-x86 -// FIXME(#114479): LLVM miscompiles loading and storing `f32` and `f64` when SSE is disabled. -// There's no compiletest directive to ignore a test on i586 only, so just always explicitly enable -// SSE2. -// Use the same target CPU as `i686` so that LLVM orders the instructions in the same order. -//@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4 +//@ revisions: sse nosse +//@[sse] compile-flags: --target i686-unknown-linux-gnu +//@[sse] needs-llvm-components: x86 +// We make SSE available but don't use it for the ABI. +//@[nosse] compile-flags: --target i586-unknown-linux-gnu -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4 +//@[nosse] needs-llvm-components: x86 + // Force frame pointers to make ASM more consistent between targets //@ compile-flags: -O -C force-frame-pointers //@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst -//@ revisions: normal win -//@[normal] ignore-windows -//@[win] only-windows -#![crate_type = "lib"] #![feature(f16, f128)] +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +impl Copy for f16 {} +impl Copy for f32 {} +impl Copy for f64 {} +impl Copy for f128 {} +impl Copy for usize {} // Tests that returning `f32` and `f64` with the "Rust" ABI on 32-bit x86 doesn't use the x87 // floating point stack, as loading and storing `f32`s and `f64`s to and from the x87 stack quietens @@ -24,7 +36,8 @@ // CHECK-LABEL: return_f32: #[no_mangle] pub fn return_f32(x: f32) -> f32 { - // CHECK: movl {{.*}}(%ebp), %eax + // sse: movss {{.*}}(%ebp), %xmm0 + // nosse: movl {{.*}}(%ebp), %eax // CHECK-NOT: ax // CHECK: retl x @@ -33,9 +46,11 @@ pub fn return_f32(x: f32) -> f32 { // CHECK-LABEL: return_f64: #[no_mangle] pub fn return_f64(x: f64) -> f64 { - // CHECK: movl [[#%d,OFFSET:]](%ebp), %[[PTR:.*]] - // CHECK-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL:.*]] - // CHECK-NEXT: movsd %[[VAL]], (%[[PTR]]) + // nosse: movl [[#%d,OFFSET:]](%ebp), %[[PTR:.*]] + // nosse-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL:.*]] + // nosse-NEXT: movsd %[[VAL]], (%[[PTR]]) + // sse: movsd {{.*}}(%ebp), %xmm0 + // sse-NOT: ax // CHECK: retl x } @@ -148,7 +163,8 @@ pub unsafe fn call_f32(x: &mut f32) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f32 - // CHECK-NEXT: movl %eax, (%[[PTR]]) + // sse-NEXT: movss %xmm0, (%[[PTR]]) + // nosse-NEXT: movl %eax, (%[[PTR]]) *x = get_f32(); } @@ -160,8 +176,9 @@ pub unsafe fn call_f64(x: &mut f64) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64 - // CHECK: movsd {{.*}}(%{{ebp|esp}}), %[[VAL:.*]] - // CHECK-NEXT: movsd %[[VAL:.*]], (%[[PTR]]) + // sse: movlps %xmm0, (%[[PTR]]) + // nosse: movsd {{.*}}(%{{ebp|esp}}), %[[VAL:.*]] + // nosse-NEXT: movsd %[[VAL:.*]], (%[[PTR]]) *x = get_f64(); } @@ -190,10 +207,8 @@ pub unsafe fn call_f64_f64(x: &mut (f64, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_f64 - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] - // win: movsd (%esp), %[[VAL1:.*]] - // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] + // CHECK: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // CHECK-NEXT: movsd [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) // CHECK-NEXT: movsd %[[VAL2]], 8(%[[PTR]]) *x = get_f64_f64(); @@ -207,13 +222,10 @@ pub unsafe fn call_f32_f64(x: &mut (f32, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f32_f64 - // normal: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] - // win: movss (%esp), %[[VAL1:.*]] - // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] + // CHECK: movss [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // CHECK-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movss %[[VAL1]], (%[[PTR]]) - // normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) - // win-NEXT: movsd %[[VAL2]], 8(%[[PTR]]) + // CHECK-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) *x = get_f32_f64(); } @@ -225,10 +237,8 @@ pub unsafe fn call_f64_f32(x: &mut (f64, f32)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_f32 - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] - // win: movsd (%esp), %[[VAL1:.*]] - // win-NEXT: movss 8(%esp), %[[VAL2:.*]] + // CHECK: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // CHECK-NEXT: movss [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) // CHECK-NEXT: movss %[[VAL2]], 8(%[[PTR]]) *x = get_f64_f32(); @@ -257,10 +267,8 @@ pub unsafe fn call_f64_other(x: &mut (f64, usize)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_f64_other - // normal: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] - // win: movsd (%esp), %[[VAL1:.*]] - // win-NEXT: movl 8(%esp), %[[VAL2:.*]] + // CHECK: movsd [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // CHECK-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movsd %[[VAL1]], (%[[PTR]]) // CHECK-NEXT: movl %[[VAL2]], 8(%[[PTR]]) *x = get_f64_other(); @@ -289,13 +297,10 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) { } // CHECK: movl {{.*}}(%ebp), %[[PTR:.*]] // CHECK: calll {{()|_}}get_other_f64 - // normal: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] - // normal-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] - // win: movl (%esp), %[[VAL1:.*]] - // win-NEXT: movsd 8(%esp), %[[VAL2:.*]] + // CHECK: movl [[#%d,OFFSET:]](%ebp), %[[VAL1:.*]] + // CHECK-NEXT: movsd [[#%d,OFFSET+4]](%ebp), %[[VAL2:.*]] // CHECK-NEXT: movl %[[VAL1]], (%[[PTR]]) - // normal-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) - // win-NEXT: movsd %[[VAL2]], 8(%[[PTR]]) + // CHECK-NEXT: movsd %[[VAL2]], 4(%[[PTR]]) *x = get_other_f64(); } @@ -307,7 +312,8 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) { pub fn return_f16(x: f16) -> f16 { // CHECK: pushl %ebp // CHECK: movl %esp, %ebp - // CHECK: movzwl 8(%ebp), %eax + // nosse: movzwl 8(%ebp), %eax + // sse: pinsrw $0, 8(%ebp), %xmm0 // CHECK: popl %ebp // CHECK: retl x @@ -316,15 +322,18 @@ pub fn return_f16(x: f16) -> f16 { // CHECK-LABEL: return_f128: #[no_mangle] pub fn return_f128(x: f128) -> f128 { - // CHECK: movl [[#%d,OFFSET:]](%ebp), %[[PTR:.*]] - // CHECK-NEXT: movl [[#%d,OFFSET+4]](%ebp), %[[VAL1:.*]] - // CHECK-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] - // CHECK-NEXT: movl [[#%d,OFFSET+12]](%ebp), %[[VAL3:.*]] - // CHECK-NEXT: movl [[#%d,OFFSET+16]](%ebp), %[[VAL4:.*]] - // CHECK-NEXT: movl %[[VAL4:.*]] 12(%[[PTR]]) - // CHECK-NEXT: movl %[[VAL3:.*]] 8(%[[PTR]]) - // CHECK-NEXT: movl %[[VAL2:.*]] 4(%[[PTR]]) - // CHECK-NEXT: movl %[[VAL1:.*]] (%[[PTR]]) + // CHECK: pushl %ebp + // sse: movaps [[#%d,OFFSET:]](%ebp), %xmm0 + // nosse: movl [[#%d,OFFSET:]](%ebp), %[[PTR:.*]] + // nosse-NEXT: movl [[#%d,OFFSET+4]](%ebp), %[[VAL1:.*]] + // nosse-NEXT: movl [[#%d,OFFSET+8]](%ebp), %[[VAL2:.*]] + // nosse-NEXT: movl [[#%d,OFFSET+12]](%ebp), %[[VAL3:.*]] + // nosse-NEXT: movl [[#%d,OFFSET+16]](%ebp), %[[VAL4:.*]] + // nosse-NEXT: movl %[[VAL4:.*]] 12(%[[PTR]]) + // nosse-NEXT: movl %[[VAL3:.*]] 8(%[[PTR]]) + // nosse-NEXT: movl %[[VAL2:.*]] 4(%[[PTR]]) + // nosse-NEXT: movl %[[VAL1:.*]] (%[[PTR]]) + // CHECK: popl %ebp // CHECK: retl x } diff --git a/tests/codegen/abi-repr-ext.rs b/tests/codegen/abi-repr-ext.rs index a42f73566961e..b06d225ed70e6 100644 --- a/tests/codegen/abi-repr-ext.rs +++ b/tests/codegen/abi-repr-ext.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv diff --git a/tests/codegen/abi-x86-sse.rs b/tests/codegen/abi-x86-sse.rs new file mode 100644 index 0000000000000..6a0f3dd18d472 --- /dev/null +++ b/tests/codegen/abi-x86-sse.rs @@ -0,0 +1,36 @@ +//@ compile-flags: -Z merge-functions=disabled + +//@ revisions: x86-64 +//@[x86-64] compile-flags: --target x86_64-unknown-linux-gnu +//@[x86-64] needs-llvm-components: x86 + +//@ revisions: x86-32 +//@[x86-32] compile-flags: --target i686-unknown-linux-gnu +//@[x86-32] needs-llvm-components: x86 + +//@ revisions: x86-32-nosse +//@[x86-32-nosse] compile-flags: --target i586-unknown-linux-gnu +//@[x86-32-nosse] needs-llvm-components: x86 + +#![feature(no_core, lang_items, rustc_attrs, repr_simd)] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +// Ensure this type is passed without ptr indirection on targets that +// require SSE2. +#[repr(simd)] +pub struct Sse([f32; 4]); + +// x86-64: <4 x float> @sse_id(<4 x float> {{[^,]*}}) +// x86-32: <4 x float> @sse_id(<4 x float> {{[^,]*}}) +// x86-32-nosse: void @sse_id(ptr {{[^,]*}} sret{{[^,]*}}, ptr {{[^,]*}}) +#[no_mangle] +pub fn sse_id(x: Sse) -> Sse { + x +} diff --git a/tests/codegen/align-offset.rs b/tests/codegen/align-offset.rs index aeac230f718fb..21062cc0a914b 100644 --- a/tests/codegen/align-offset.rs +++ b/tests/codegen/align-offset.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/alloc-optimisation.rs b/tests/codegen/alloc-optimisation.rs index 6f320e68fdb30..8abeecf8550be 100644 --- a/tests/codegen/alloc-optimisation.rs +++ b/tests/codegen/alloc-optimisation.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/array-clone.rs b/tests/codegen/array-clone.rs index 2873f3cadca82..35445174684f9 100644 --- a/tests/codegen/array-clone.rs +++ b/tests/codegen/array-clone.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs index fc272f2556cbf..9b0c6e8c3472e 100644 --- a/tests/codegen/array-codegen.rs +++ b/tests/codegen/array-codegen.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/array-equality.rs b/tests/codegen/array-equality.rs index bc5425c7a4f4e..fa0475bf4809c 100644 --- a/tests/codegen/array-equality.rs +++ b/tests/codegen/array-equality.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/array-optimized.rs b/tests/codegen/array-optimized.rs index 42fdbd39b7efa..000163d5519b3 100644 --- a/tests/codegen/array-optimized.rs +++ b/tests/codegen/array-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/array-repeat.rs b/tests/codegen/array-repeat.rs index b6f3b2e83d3e1..4c755df939034 100644 --- a/tests/codegen/array-repeat.rs +++ b/tests/codegen/array-repeat.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(array_repeat)] diff --git a/tests/codegen/asm/goto.rs b/tests/codegen/asm/goto.rs index c40a43fbe1bd3..7a87bb7983bae 100644 --- a/tests/codegen/asm/goto.rs +++ b/tests/codegen/asm/goto.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/may_unwind.rs b/tests/codegen/asm/may_unwind.rs index be66b3975ff87..63cdec7584c9b 100644 --- a/tests/codegen/asm/may_unwind.rs +++ b/tests/codegen/asm/may_unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/maybe-uninit.rs b/tests/codegen/asm/maybe-uninit.rs index 55813c35a468b..d76d5cb1312e2 100644 --- a/tests/codegen/asm/maybe-uninit.rs +++ b/tests/codegen/asm/maybe-uninit.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/multiple-options.rs b/tests/codegen/asm/multiple-options.rs index 1ee295e32c9e9..4d87471a1939d 100644 --- a/tests/codegen/asm/multiple-options.rs +++ b/tests/codegen/asm/multiple-options.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/options.rs b/tests/codegen/asm/options.rs index 96a72c2f5ae90..c087f91fd4343 100644 --- a/tests/codegen/asm/options.rs +++ b/tests/codegen/asm/options.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/x86-clobber_abi.rs b/tests/codegen/asm/x86-clobber_abi.rs index cc563474bf8c2..5b34b4e8ef312 100644 --- a/tests/codegen/asm/x86-clobber_abi.rs +++ b/tests/codegen/asm/x86-clobber_abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/asm/x86-clobbers.rs b/tests/codegen/asm/x86-clobbers.rs index 4094db7413468..50163b646b257 100644 --- a/tests/codegen/asm/x86-clobbers.rs +++ b/tests/codegen/asm/x86-clobbers.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "rlib"] diff --git a/tests/codegen/atomic-operations.rs b/tests/codegen/atomic-operations.rs index 8a70c94e48053..8771b8b241998 100644 --- a/tests/codegen/atomic-operations.rs +++ b/tests/codegen/atomic-operations.rs @@ -1,5 +1,5 @@ // Code generation of atomic operations. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::sync::atomic::AtomicI32; diff --git a/tests/codegen/atomicptr.rs b/tests/codegen/atomicptr.rs index e8c5e6a674970..4819af40ca2d2 100644 --- a/tests/codegen/atomicptr.rs +++ b/tests/codegen/atomicptr.rs @@ -4,7 +4,7 @@ // ensures that we do not have such a round-trip for AtomicPtr::swap, because LLVM supports pointer // arguments to `atomicrmw xchg`. -//@ compile-flags: -O -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes #![crate_type = "lib"] #![feature(strict_provenance_atomic_ptr)] diff --git a/tests/codegen/autodiff.rs b/tests/codegen/autodiff.rs new file mode 100644 index 0000000000000..abf7fcf3e4bcd --- /dev/null +++ b/tests/codegen/autodiff.rs @@ -0,0 +1,33 @@ +//@ compile-flags: -C opt-level=3 -Clto=fat +//@ no-prefer-dynamic +//@ needs-enzyme +#![feature(autodiff)] + +use std::autodiff::autodiff; + +#[autodiff(d_square, Reverse, Duplicated, Active)] +#[no_mangle] +fn square(x: &f64) -> f64 { + x * x +} + +// CHECK:define internal fastcc double @diffesquare(double %x.0.val, ptr nocapture align 8 %"x'" +// CHECK-NEXT:invertstart: +// CHECK-NEXT: %_0 = fmul double %x.0.val, %x.0.val +// CHECK-NEXT: %0 = fadd fast double %x.0.val, %x.0.val +// CHECK-NEXT: %1 = load double, ptr %"x'", align 8 +// CHECK-NEXT: %2 = fadd fast double %1, %0 +// CHECK-NEXT: store double %2, ptr %"x'", align 8 +// CHECK-NEXT: ret double %_0 +// CHECK-NEXT:} + +fn main() { + let x = 3.0; + let output = square(&x); + assert_eq!(9.0, output); + + let mut df_dx = 0.0; + let output_ = d_square(&x, &mut df_dx, 1.0); + assert_eq!(output, output_); + assert_eq!(6.0, df_dx); +} diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index 7a36490fe93b8..ed8acccb1ad85 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target=avr-unknown-gnu-atmega328 --crate-type=rlib -C panic=abort +//@ compile-flags: -Copt-level=3 --target=avr-unknown-gnu-atmega328 --crate-type=rlib -C panic=abort //@ needs-llvm-components: avr // This test validates that function pointers can be stored in global variables diff --git a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs index e3bc9a4761cfd..2c40327f62454 100644 --- a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs +++ b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions #![crate_type = "lib"] diff --git a/tests/codegen/binary-search-index-no-bound-check.rs b/tests/codegen/binary-search-index-no-bound-check.rs index a213c015a40b3..d59c0beec6419 100644 --- a/tests/codegen/binary-search-index-no-bound-check.rs +++ b/tests/codegen/binary-search-index-no-bound-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted when slicing or indexing diff --git a/tests/codegen/box-uninit-bytes.rs b/tests/codegen/box-uninit-bytes.rs index 63a6c7b841560..3b83ef3e250c4 100644 --- a/tests/codegen/box-uninit-bytes.rs +++ b/tests/codegen/box-uninit-bytes.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::mem::MaybeUninit; diff --git a/tests/codegen/call-metadata.rs b/tests/codegen/call-metadata.rs index b986b4467face..7ad3ded2f09de 100644 --- a/tests/codegen/call-metadata.rs +++ b/tests/codegen/call-metadata.rs @@ -1,7 +1,7 @@ // Checks that range metadata gets emitted on calls to functions returning a // scalar value. -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ max-llvm-major-version: 18 #![crate_type = "lib"] diff --git a/tests/codegen/cast-optimized.rs b/tests/codegen/cast-optimized.rs index 59cf40935cd54..11220c4a922b1 100644 --- a/tests/codegen/cast-optimized.rs +++ b/tests/codegen/cast-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or diff --git a/tests/codegen/cast-target-abi.rs b/tests/codegen/cast-target-abi.rs index b3a35cbf3b1c6..a0801eb982692 100644 --- a/tests/codegen/cast-target-abi.rs +++ b/tests/codegen/cast-target-abi.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength //@ revisions:aarch64 loongarch64 powerpc64 sparc64 x86_64 //@ min-llvm-version: 19 -//@ compile-flags: -O -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu //@[aarch64] needs-llvm-components: arm diff --git a/tests/codegen/catch-unwind.rs b/tests/codegen/catch-unwind.rs index 48ad486fa03a6..d1ff55bcc285b 100644 --- a/tests/codegen/catch-unwind.rs +++ b/tests/codegen/catch-unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // On x86 the closure is inlined in foo() producing something like // define i32 @foo() [...] { diff --git a/tests/codegen/char-ascii-branchless.rs b/tests/codegen/char-ascii-branchless.rs index 76d2f617ed1cd..f99066aa9aaec 100644 --- a/tests/codegen/char-ascii-branchless.rs +++ b/tests/codegen/char-ascii-branchless.rs @@ -1,6 +1,6 @@ // Checks that these functions are branchless. // -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/checked_ilog.rs b/tests/codegen/checked_ilog.rs index d7dfc7c29e7da..e340a45b6a96d 100644 --- a/tests/codegen/checked_ilog.rs +++ b/tests/codegen/checked_ilog.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/checked_math.rs b/tests/codegen/checked_math.rs index c612ddccdaa46..66667c6948818 100644 --- a/tests/codegen/checked_math.rs +++ b/tests/codegen/checked_math.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(unchecked_shifts)] diff --git a/tests/codegen/classify-fp-category-of-usize-without-branch.rs b/tests/codegen/classify-fp-category-of-usize-without-branch.rs new file mode 100644 index 0000000000000..57184fd75e959 --- /dev/null +++ b/tests/codegen/classify-fp-category-of-usize-without-branch.rs @@ -0,0 +1,56 @@ +//@ compile-flags: -C opt-level=3 +//@ ignore-arm-unknown-linux-gnueabi very different IR compared to other targets +//@ ignore-arm-unknown-linux-gnueabihf +//@ ignore-arm-unknown-linux-musleabi +//@ ignore-arm-unknown-linux-musleabihf +//! Ensure that classifying `FpCategory` based on `usize` compiles to +//! a handful of instructions without any `switch` or branches. +//! This regressed between rustc 1.37 and 1.38 and was discovered +//! in issue #74615. + +#![crate_type = "lib"] + +use std::num::FpCategory; + +fn conv(input: u32) -> FpCategory { + match input { + 0b10000000 | 0b00000001 => FpCategory::Infinite, + 0b01000000 | 0b00000010 => FpCategory::Normal, + 0b00100000 | 0b00000100 => FpCategory::Subnormal, + 0b00010000 | 0b00001000 => FpCategory::Zero, + 0b100000000 | 0b1000000000 => FpCategory::Nan, + _ => unsafe { std::hint::unreachable_unchecked() }, + } +} + +#[no_mangle] +pub fn complex_test(input: u32) -> bool { + // CHECK-LABEL: @complex_test( + // CHECK: [[TMP0:%.*]] = tail call + // CHECK: [[DOTOFF:%.*]] = add nsw i32 [[TMP0]], -3 + // CHECK: [[SWITCH:%.*]] = icmp ult i32 [[DOTOFF]], 2 + // CHECK-NOT: switch i32 + // CHECK-NOT: br + // CHECK-NOT: label + // CHECK: ret i1 [[SWITCH]] + // + conv(input) == FpCategory::Zero +} + +#[no_mangle] +pub fn simpler_test(input: u32) -> bool { + // CHECK-LABEL: @simpler_test( + // CHECK-SAME: i32 noundef [[INPUT:%.*]]) + // CHECK: [[TMP0:%.*]] = add i32 [[INPUT]], -8 + // CHECK: [[SWITCH_AND:%.*]] = and i32 [[TMP0]], -9 + // CHECK: [[SWITCH_SELECTCMP:%.*]] = icmp eq i32 [[SWITCH_AND]], 0 + // CHECK-NOT: switch i32 + // CHECK-NOT: br + // CHECK-NOT: label + // CHECK: ret i1 [[SWITCH_SELECTCMP]] + // + match input { + 0b00010000 | 0b00001000 => true, + _ => false, + } +} diff --git a/tests/codegen/clone_as_copy.rs b/tests/codegen/clone_as_copy.rs index 6ba198297e226..c39f120044c09 100644 --- a/tests/codegen/clone_as_copy.rs +++ b/tests/codegen/clone_as_copy.rs @@ -1,7 +1,7 @@ //@ revisions: DEBUGINFO NODEBUGINFO //@ compile-flags: -Zunsound-mir-opts // FIXME: see -//@ compile-flags: -O -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes //@ [DEBUGINFO] compile-flags: -Cdebuginfo=full // From https://github.com/rust-lang/rust/issues/128081. diff --git a/tests/codegen/common_prim_int_ptr.rs b/tests/codegen/common_prim_int_ptr.rs index aa7ebb4c9119d..8eb0502417417 100644 --- a/tests/codegen/common_prim_int_ptr.rs +++ b/tests/codegen/common_prim_int_ptr.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/const-array.rs b/tests/codegen/const-array.rs index f2b331c315dce..e257d8acc0881 100644 --- a/tests/codegen/const-array.rs +++ b/tests/codegen/const-array.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/always-inline.rs b/tests/codegen/cross-crate-inlining/always-inline.rs index d3a35dadb67bc..df28b3fe197cd 100644 --- a/tests/codegen/cross-crate-inlining/always-inline.rs +++ b/tests/codegen/cross-crate-inlining/always-inline.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:always.rs #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/always.rs b/tests/codegen/cross-crate-inlining/auxiliary/always.rs index 7f524e17d34a1..6ee3f81e3c879 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/always.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/always.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=always +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=always #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs b/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs index 5895812b5ee51..d059a3d0a73b8 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/leaf.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/auxiliary/never.rs b/tests/codegen/cross-crate-inlining/auxiliary/never.rs index 3a391608df849..55c90809ec18f 100644 --- a/tests/codegen/cross-crate-inlining/auxiliary/never.rs +++ b/tests/codegen/cross-crate-inlining/auxiliary/never.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=never +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=never #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/leaf-inlining.rs b/tests/codegen/cross-crate-inlining/leaf-inlining.rs index b47898f750a24..37132312ca94c 100644 --- a/tests/codegen/cross-crate-inlining/leaf-inlining.rs +++ b/tests/codegen/cross-crate-inlining/leaf-inlining.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zcross-crate-inline-threshold=yes +//@ compile-flags: -Copt-level=3 -Zcross-crate-inline-threshold=yes //@ aux-build:leaf.rs #![crate_type = "lib"] diff --git a/tests/codegen/cross-crate-inlining/never-inline.rs b/tests/codegen/cross-crate-inlining/never-inline.rs index eedf90ceec0fc..759f65d9d42b2 100644 --- a/tests/codegen/cross-crate-inlining/never-inline.rs +++ b/tests/codegen/cross-crate-inlining/never-inline.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:never.rs #![crate_type = "lib"] diff --git a/tests/codegen/dealloc-no-unwind.rs b/tests/codegen/dealloc-no-unwind.rs index ead26da610e25..c560d7a993209 100644 --- a/tests/codegen/dealloc-no-unwind.rs +++ b/tests/codegen/dealloc-no-unwind.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/debug-fndef-size.rs b/tests/codegen/debug-fndef-size.rs index c58a8228967a4..8f716c34e7b74 100644 --- a/tests/codegen/debug-fndef-size.rs +++ b/tests/codegen/debug-fndef-size.rs @@ -1,7 +1,7 @@ // Verify that `i32::cmp` FnDef type is declared with a size of 0 and an // alignment of 8 bits (1 byte) in LLVM debuginfo. -//@ compile-flags: -O -g -Cno-prepopulate-passes +//@ compile-flags: -Copt-level=3 -g -Cno-prepopulate-passes //@ ignore-msvc the types are mangled differently use std::cmp::Ordering; diff --git a/tests/codegen/debuginfo-constant-locals.rs b/tests/codegen/debuginfo-constant-locals.rs index c8f1d964722ef..580c69c05a54d 100644 --- a/tests/codegen/debuginfo-constant-locals.rs +++ b/tests/codegen/debuginfo-constant-locals.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -g -O +//@ compile-flags: -g -Copt-level=3 // Check that simple constant values are preserved in debuginfo across both MIR opts and LLVM opts diff --git a/tests/codegen/debuginfo-inline-callsite-location.rs b/tests/codegen/debuginfo-inline-callsite-location.rs index c31788d82db32..59ade52ad3276 100644 --- a/tests/codegen/debuginfo-inline-callsite-location.rs +++ b/tests/codegen/debuginfo-inline-callsite-location.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -g -O -C panic=abort +//@ compile-flags: -g -Copt-level=3 -C panic=abort // Check that each inline call site for the same function uses the same "sub-program" so that LLVM // can correctly merge the debug info if it merges the inlined code (e.g., for merging of tail diff --git a/tests/codegen/deduced-param-attrs.rs b/tests/codegen/deduced-param-attrs.rs index 5e7c571b63f8d..22db090d4d889 100644 --- a/tests/codegen/deduced-param-attrs.rs +++ b/tests/codegen/deduced-param-attrs.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![allow(incomplete_features)] diff --git a/tests/codegen/dont-shuffle-bswaps.rs b/tests/codegen/dont-shuffle-bswaps.rs new file mode 100644 index 0000000000000..9a6f5862f9adf --- /dev/null +++ b/tests/codegen/dont-shuffle-bswaps.rs @@ -0,0 +1,36 @@ +//@ revisions: OPT2 OPT3 +//@[OPT2] compile-flags: -Copt-level=2 +//@[OPT3] compile-flags: -C opt-level=3 +//@ min-llvm-version: 18.1.3 + +#![crate_type = "lib"] +#![no_std] + +// The code is from https://github.com/rust-lang/rust/issues/122805. +// Ensure we do not generate the shufflevector instruction +// to avoid complicating the code. +// CHECK-LABEL: define{{.*}}void @convert( +// CHECK-NOT: shufflevector +// On higher opt levels, this should just be a bswap: +// OPT3: load <8 x i16> +// OPT3-NEXT: call <8 x i16> @llvm.bswap +// OPT3-NEXT: store <8 x i16> +// OPT3-NEXT: ret void +#[no_mangle] +pub fn convert(value: [u16; 8]) -> [u8; 16] { + #[cfg(target_endian = "little")] + let bswap = u16::to_be; + #[cfg(target_endian = "big")] + let bswap = u16::to_le; + let addr16 = [ + bswap(value[0]), + bswap(value[1]), + bswap(value[2]), + bswap(value[3]), + bswap(value[4]), + bswap(value[5]), + bswap(value[6]), + bswap(value[7]), + ]; + unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) } +} diff --git a/tests/codegen/drop-in-place-noalias.rs b/tests/codegen/drop-in-place-noalias.rs index 2dc769df1c92b..bff2f52781f23 100644 --- a/tests/codegen/drop-in-place-noalias.rs +++ b/tests/codegen/drop-in-place-noalias.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes // Tests that the compiler can apply `noalias` and other &mut attributes to `drop_in_place`. // Note that non-Unpin types should not get `noalias`, matching &mut behavior. diff --git a/tests/codegen/dst-vtable-align-nonzero.rs b/tests/codegen/dst-vtable-align-nonzero.rs index cb07e43238c10..1404bd64f500c 100644 --- a/tests/codegen/dst-vtable-align-nonzero.rs +++ b/tests/codegen/dst-vtable-align-nonzero.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/dst-vtable-size-range.rs b/tests/codegen/dst-vtable-size-range.rs index 69d8e68497ca6..670f5e8d553fa 100644 --- a/tests/codegen/dst-vtable-size-range.rs +++ b/tests/codegen/dst-vtable-size-range.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/emscripten-catch-unwind-js-eh.rs b/tests/codegen/emscripten-catch-unwind-js-eh.rs index b15fb40b68f00..018ad5454fc23 100644 --- a/tests/codegen/emscripten-catch-unwind-js-eh.rs +++ b/tests/codegen/emscripten-catch-unwind-js-eh.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target wasm32-unknown-emscripten +//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten //@ needs-llvm-components: webassembly // Emscripten has its own unique implementation of catch_unwind (in `codegen_emcc_try`), diff --git a/tests/codegen/emscripten-catch-unwind-wasm-eh.rs b/tests/codegen/emscripten-catch-unwind-wasm-eh.rs index 72395f432d5f8..0fc9ae96720e4 100644 --- a/tests/codegen/emscripten-catch-unwind-wasm-eh.rs +++ b/tests/codegen/emscripten-catch-unwind-wasm-eh.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --target wasm32-unknown-emscripten -Z emscripten-wasm-eh +//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten -Z emscripten-wasm-eh //@ needs-llvm-components: webassembly // Emscripten catch_unwind using wasm exceptions diff --git a/tests/codegen/enum/enum-bounds-check-derived-idx.rs b/tests/codegen/enum/enum-bounds-check-derived-idx.rs index 15280cb2e6c87..a5785f4addf05 100644 --- a/tests/codegen/enum/enum-bounds-check-derived-idx.rs +++ b/tests/codegen/enum/enum-bounds-check-derived-idx.rs @@ -1,6 +1,6 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check-issue-13926.rs b/tests/codegen/enum/enum-bounds-check-issue-13926.rs index b60ff38ce392c..6e8e5035b0d00 100644 --- a/tests/codegen/enum/enum-bounds-check-issue-13926.rs +++ b/tests/codegen/enum/enum-bounds-check-issue-13926.rs @@ -1,6 +1,6 @@ // This test checks an optimization that is not guaranteed to work. This test case should not block // a future LLVM update. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs index c44c007ed6a9f..5362598ca7c43 100644 --- a/tests/codegen/enum/enum-bounds-check.rs +++ b/tests/codegen/enum/enum-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/enum-early-otherwise-branch.rs b/tests/codegen/enum/enum-early-otherwise-branch.rs index 07c8aed2624c1..8d39d8e9b7466 100644 --- a/tests/codegen/enum/enum-early-otherwise-branch.rs +++ b/tests/codegen/enum/enum-early-otherwise-branch.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/enum/unreachable_enum_default_branch.rs b/tests/codegen/enum/unreachable_enum_default_branch.rs index 76a92496c0729..55b165fc111dd 100644 --- a/tests/codegen/enum/unreachable_enum_default_branch.rs +++ b/tests/codegen/enum/unreachable_enum_default_branch.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/error-provide.rs b/tests/codegen/error-provide.rs index 68dd383e5cce0..25a66078fd4a8 100644 --- a/tests/codegen/error-provide.rs +++ b/tests/codegen/error-provide.rs @@ -1,6 +1,6 @@ // Codegen test for #126242 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(error_generic_member_access)] use std::error::Request; diff --git a/tests/codegen/external-no-mangle-statics.rs b/tests/codegen/external-no-mangle-statics.rs index a44867ff9230f..dc4eca8c7b486 100644 --- a/tests/codegen/external-no-mangle-statics.rs +++ b/tests/codegen/external-no-mangle-statics.rs @@ -1,6 +1,6 @@ //@ revisions: lib staticlib //@ ignore-emscripten default visibility is hidden -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [lib] compile-flags: --crate-type lib //@ [staticlib] compile-flags: --crate-type staticlib // `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their diff --git a/tests/codegen/f128-wasm32-callconv.rs b/tests/codegen/f128-wasm32-callconv.rs index 8b1b5e7fb013f..7dccbda18f1aa 100644 --- a/tests/codegen/f128-wasm32-callconv.rs +++ b/tests/codegen/f128-wasm32-callconv.rs @@ -1,7 +1,7 @@ //! Verify that Rust implements the expected calling convention for `f128` //@ add-core-stubs -//@ compile-flags: -O --target wasm32-wasip1 +//@ compile-flags: -Copt-level=3 --target wasm32-wasip1 //@ needs-llvm-components: webassembly #![crate_type = "lib"] diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index 2459ec1539e43..00b390bf1bf17 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -2,7 +2,7 @@ // as "inreg" like the C/C++ compilers for the platforms. // x86 only. -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 #![crate_type = "lib"] diff --git a/tests/codegen/fewer-names.rs b/tests/codegen/fewer-names.rs index a171629a076b2..ff7a916b619c1 100644 --- a/tests/codegen/fewer-names.rs +++ b/tests/codegen/fewer-names.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Coverflow-checks=no -O +//@ compile-flags: -Coverflow-checks=no -Copt-level=3 //@ revisions: YES NO //@ [YES]compile-flags: -Zfewer-names=yes //@ [NO] compile-flags: -Zfewer-names=no diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index 1a211dfe096b3..f0708a7a109f2 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(rustc_attrs)] #![feature(dyn_star)] diff --git a/tests/codegen/hint/cold_path.rs b/tests/codegen/hint/cold_path.rs index dac72073f858b..149abe474f67b 100644 --- a/tests/codegen/hint/cold_path.rs +++ b/tests/codegen/hint/cold_path.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(cold_path)] diff --git a/tests/codegen/hint/likely.rs b/tests/codegen/hint/likely.rs index 2f589cc99d282..75f9e7aae367d 100644 --- a/tests/codegen/hint/likely.rs +++ b/tests/codegen/hint/likely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(likely_unlikely)] diff --git a/tests/codegen/hint/unlikely.rs b/tests/codegen/hint/unlikely.rs index 328533f30816c..248b1e2537e96 100644 --- a/tests/codegen/hint/unlikely.rs +++ b/tests/codegen/hint/unlikely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(likely_unlikely)] diff --git a/tests/codegen/i128-wasm32-callconv.rs b/tests/codegen/i128-wasm32-callconv.rs index c6d25fbe8bea2..9d73d270ef3d0 100644 --- a/tests/codegen/i128-wasm32-callconv.rs +++ b/tests/codegen/i128-wasm32-callconv.rs @@ -1,7 +1,7 @@ //! Verify that Rust implements the expected calling convention for `i128`/`u128`. //@ add-core-stubs -//@ compile-flags: -O --target wasm32-wasip1 +//@ compile-flags: -Copt-level=3 --target wasm32-wasip1 //@ needs-llvm-components: webassembly #![crate_type = "lib"] diff --git a/tests/codegen/i128-x86-align.rs b/tests/codegen/i128-x86-align.rs index ac101b72513dd..75802b0c5056a 100644 --- a/tests/codegen/i128-x86-align.rs +++ b/tests/codegen/i128-x86-align.rs @@ -1,5 +1,5 @@ //@ only-x86_64 -//@ compile-flags: -O -C no-prepopulate-passes --crate-type=lib +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --crate-type=lib // On LLVM 17 and earlier LLVM's own data layout specifies that i128 has 8 byte alignment, // while rustc wants it to have 16 byte alignment. This test checks that we handle this diff --git a/tests/codegen/integer-overflow.rs b/tests/codegen/integer-overflow.rs index a6407476fc209..80362247a86f1 100644 --- a/tests/codegen/integer-overflow.rs +++ b/tests/codegen/integer-overflow.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C overflow-checks=on +//@ compile-flags: -Copt-level=3 -C overflow-checks=on #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/aggregate-thin-pointer.rs b/tests/codegen/intrinsics/aggregate-thin-pointer.rs index aa3bf7e8b14a4..bd590ce91809f 100644 --- a/tests/codegen/intrinsics/aggregate-thin-pointer.rs +++ b/tests/codegen/intrinsics/aggregate-thin-pointer.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mir-enable-passes=-InstSimplify +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mir-enable-passes=-InstSimplify //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/cold_path.rs b/tests/codegen/intrinsics/cold_path.rs index 24ee84e07bf1d..fd75324b671e2 100644 --- a/tests/codegen/intrinsics/cold_path.rs +++ b/tests/codegen/intrinsics/cold_path.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/compare_bytes.rs b/tests/codegen/intrinsics/compare_bytes.rs index cd592918fb0c2..3ab0e4e97e09d 100644 --- a/tests/codegen/intrinsics/compare_bytes.rs +++ b/tests/codegen/intrinsics/compare_bytes.rs @@ -1,5 +1,5 @@ //@ revisions: INT32 INT16 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ [INT32] ignore-16bit //@ [INT16] only-16bit diff --git a/tests/codegen/intrinsics/likely.rs b/tests/codegen/intrinsics/likely.rs index e318390db205c..c5e3c466f4525 100644 --- a/tests/codegen/intrinsics/likely.rs +++ b/tests/codegen/intrinsics/likely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/likely_assert.rs b/tests/codegen/intrinsics/likely_assert.rs index 0ddbd6206aeea..87ffb4ee3fb65 100644 --- a/tests/codegen/intrinsics/likely_assert.rs +++ b/tests/codegen/intrinsics/likely_assert.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/intrinsics/nontemporal.rs b/tests/codegen/intrinsics/nontemporal.rs index ff2d629606688..af8892d30e7f4 100644 --- a/tests/codegen/intrinsics/nontemporal.rs +++ b/tests/codegen/intrinsics/nontemporal.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@revisions: with_nontemporal without_nontemporal //@[with_nontemporal] compile-flags: --target aarch64-unknown-linux-gnu //@[with_nontemporal] needs-llvm-components: aarch64 diff --git a/tests/codegen/intrinsics/offset.rs b/tests/codegen/intrinsics/offset.rs index d4791cd30b0be..d76d3e705abad 100644 --- a/tests/codegen/intrinsics/offset.rs +++ b/tests/codegen/intrinsics/offset.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/intrinsics/ptr_metadata.rs b/tests/codegen/intrinsics/ptr_metadata.rs index f4bf5a1f5f173..87a32fa3d2468 100644 --- a/tests/codegen/intrinsics/ptr_metadata.rs +++ b/tests/codegen/intrinsics/ptr_metadata.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z inline-mir +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z inline-mir //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/select_unpredictable.rs b/tests/codegen/intrinsics/select_unpredictable.rs index ea6127a48bf3f..68a02c8342d06 100644 --- a/tests/codegen/intrinsics/select_unpredictable.rs +++ b/tests/codegen/intrinsics/select_unpredictable.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![feature(core_intrinsics)] #![feature(select_unpredictable)] diff --git a/tests/codegen/intrinsics/transmute-x64.rs b/tests/codegen/intrinsics/transmute-x64.rs index ea1c6b0e7e801..ee474bebff1b9 100644 --- a/tests/codegen/intrinsics/transmute-x64.rs +++ b/tests/codegen/intrinsics/transmute-x64.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-x86_64 (it's using arch-specific types) #![crate_type = "lib"] @@ -9,9 +9,10 @@ use std::mem::transmute; // CHECK-LABEL: @check_sse_float_to_int( #[no_mangle] pub unsafe fn check_sse_float_to_int(x: __m128) -> __m128i { - // CHECK-NOT: alloca - // CHECK: %0 = load <4 x float>, ptr %x, align 16 - // CHECK: store <4 x float> %0, ptr %_0, align 16 + // FIXME: the MIR opt still works, but the ABI logic now introduces + // an alloca here. + // CHECK: alloca + // CHECK: store <4 x float> %x, ptr %_0, align 16 transmute(x) } diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index 8c8e975d327a2..541333a52b0df 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-64bit (so I don't need to worry about usize) #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/unlikely.rs b/tests/codegen/intrinsics/unlikely.rs index 2d776031a52ef..90ebf070d2700 100644 --- a/tests/codegen/intrinsics/unlikely.rs +++ b/tests/codegen/intrinsics/unlikely.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(core_intrinsics)] diff --git a/tests/codegen/is_val_statically_known.rs b/tests/codegen/is_val_statically_known.rs index fe432d3bcc4de..8119d3a3bf678 100644 --- a/tests/codegen/is_val_statically_known.rs +++ b/tests/codegen/is_val_statically_known.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --crate-type=lib -Zmerge-functions=disabled -O +//@ compile-flags: --crate-type=lib -Zmerge-functions=disabled -Copt-level=3 #![feature(core_intrinsics)] #![feature(f16, f128)] diff --git a/tests/codegen/issues/issue-101048.rs b/tests/codegen/issues/issue-101048.rs index fa6dc550f301e..cfe65e758fdbd 100644 --- a/tests/codegen/issues/issue-101048.rs +++ b/tests/codegen/issues/issue-101048.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-101082.rs b/tests/codegen/issues/issue-101082.rs index 4be1b6cb168e8..048b69d207b6d 100644 --- a/tests/codegen/issues/issue-101082.rs +++ b/tests/codegen/issues/issue-101082.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ revisions: host x86-64-v3 // This particular CPU regressed in #131563 diff --git a/tests/codegen/issues/issue-101814.rs b/tests/codegen/issues/issue-101814.rs index e3843e9edb0bd..668ec8476e8c0 100644 --- a/tests/codegen/issues/issue-101814.rs +++ b/tests/codegen/issues/issue-101814.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103132.rs b/tests/codegen/issues/issue-103132.rs index 8c1a17c8b78c2..623cab92806dc 100644 --- a/tests/codegen/issues/issue-103132.rs +++ b/tests/codegen/issues/issue-103132.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C overflow-checks +//@ compile-flags: -Copt-level=3 -C overflow-checks #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs index 122f02fbbc55b..3ada5412e8335 100644 --- a/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs +++ b/tests/codegen/issues/issue-103285-ptr-addr-overflow-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C debug-assertions=yes +//@ compile-flags: -Copt-level=3 -C debug-assertions=yes #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103327.rs b/tests/codegen/issues/issue-103327.rs index f8cf273e4a6c2..4de3cfd12a09a 100644 --- a/tests/codegen/issues/issue-103327.rs +++ b/tests/codegen/issues/issue-103327.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-103840.rs b/tests/codegen/issues/issue-103840.rs index 14f157771e077..c6c5098bdd04f 100644 --- a/tests/codegen/issues/issue-103840.rs +++ b/tests/codegen/issues/issue-103840.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] pub fn foo(t: &mut Vec) { diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index db9eeda19a6c6..848aa910b584e 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates +//@ compile-flags: --crate-type=lib -Copt-level=3 -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates // MIR SROA will decompose the closure #![feature(stmt_expr_attributes)] diff --git a/tests/codegen/issues/issue-106369.rs b/tests/codegen/issues/issue-106369.rs index fd375e4e60584..3583d20c9fa1c 100644 --- a/tests/codegen/issues/issue-106369.rs +++ b/tests/codegen/issues/issue-106369.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-107681-unwrap_unchecked.rs b/tests/codegen/issues/issue-107681-unwrap_unchecked.rs index 7d9679d2322b2..fd7296de4c864 100644 --- a/tests/codegen/issues/issue-107681-unwrap_unchecked.rs +++ b/tests/codegen/issues/issue-107681-unwrap_unchecked.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 // Test for #107681. diff --git a/tests/codegen/issues/issue-108395-branchy-bool-match.rs b/tests/codegen/issues/issue-108395-branchy-bool-match.rs index 24f5c0f663532..96387e791b03a 100644 --- a/tests/codegen/issues/issue-108395-branchy-bool-match.rs +++ b/tests/codegen/issues/issue-108395-branchy-bool-match.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled //! Test for . Check that //! matching on two bools with wildcards does not produce branches. #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-109328-split_first.rs b/tests/codegen/issues/issue-109328-split_first.rs index 7f7957593d2de..26235edfc190f 100644 --- a/tests/codegen/issues/issue-109328-split_first.rs +++ b/tests/codegen/issues/issue-109328-split_first.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-110797-enum-jump-same.rs b/tests/codegen/issues/issue-110797-enum-jump-same.rs index f114e0e260eb5..b5f7c08795bc6 100644 --- a/tests/codegen/issues/issue-110797-enum-jump-same.rs +++ b/tests/codegen/issues/issue-110797-enum-jump-same.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs index 41bfb493ff580..2ba5a3f876aed 100644 --- a/tests/codegen/issues/issue-111603.rs +++ b/tests/codegen/issues/issue-111603.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(get_mut_unchecked, new_uninit)] diff --git a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs index aee2edd8dfad2..3909b203d0897 100644 --- a/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs +++ b/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @write_u8_variant_a diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs index be5b999afd0b0..e9418249089dd 100644 --- a/tests/codegen/issues/issue-114312.rs +++ b/tests/codegen/issues/issue-114312.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64-unknown-linux-gnu // We want to check that this function does not mis-optimize to loop jumping. diff --git a/tests/codegen/issues/issue-115385-llvm-jump-threading.rs b/tests/codegen/issues/issue-115385-llvm-jump-threading.rs index 55aa69a7de034..8cabd94f2028c 100644 --- a/tests/codegen/issues/issue-115385-llvm-jump-threading.rs +++ b/tests/codegen/issues/issue-115385-llvm-jump-threading.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Ccodegen-units=1 +//@ compile-flags: -Copt-level=3 -Ccodegen-units=1 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-116878.rs b/tests/codegen/issues/issue-116878.rs index a09fac42c0182..daf46c8bb554a 100644 --- a/tests/codegen/issues/issue-116878.rs +++ b/tests/codegen/issues/issue-116878.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] /// Make sure no bounds checks are emitted after a `get_unchecked`. diff --git a/tests/codegen/issues/issue-118306.rs b/tests/codegen/issues/issue-118306.rs index 0778ab3fde970..f9f3e0c0529cf 100644 --- a/tests/codegen/issues/issue-118306.rs +++ b/tests/codegen/issues/issue-118306.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 //@ only-x86_64 diff --git a/tests/codegen/issues/issue-118392.rs b/tests/codegen/issues/issue-118392.rs index ce2332b4c3c75..07de8d9b237a7 100644 --- a/tests/codegen/issues/issue-118392.rs +++ b/tests/codegen/issues/issue-118392.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @div2 diff --git a/tests/codegen/issues/issue-119422.rs b/tests/codegen/issues/issue-119422.rs index 682430a79f4a9..e1a082c377f8b 100644 --- a/tests/codegen/issues/issue-119422.rs +++ b/tests/codegen/issues/issue-119422.rs @@ -1,7 +1,7 @@ //! This test checks that compiler don't generate useless compares to zeros //! for `NonZero` integer types. //! -//@ compile-flags: -O --edition=2021 -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 --edition=2021 -Zmerge-functions=disabled //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-121719-common-field-offset.rs b/tests/codegen/issues/issue-121719-common-field-offset.rs index 11a8aa8dcd144..9f5f44e037555 100644 --- a/tests/codegen/issues/issue-121719-common-field-offset.rs +++ b/tests/codegen/issues/issue-121719-common-field-offset.rs @@ -1,7 +1,7 @@ //! This test checks that match branches which all access a field //! at the same offset are merged together. //! -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[repr(C)] diff --git a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs index 4b520a6206951..fdb8f06df8005 100644 --- a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs +++ b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-122805.rs b/tests/codegen/issues/issue-122805.rs deleted file mode 100644 index 16dae801ee43a..0000000000000 --- a/tests/codegen/issues/issue-122805.rs +++ /dev/null @@ -1,58 +0,0 @@ -//@ revisions: OPT2 OPT3WINX64 OPT3LINX64 -//@ [OPT2] compile-flags: -O -//@ [OPT3LINX64] compile-flags: -C opt-level=3 -//@ [OPT3WINX64] compile-flags: -C opt-level=3 -//@ [OPT3LINX64] only-linux -//@ [OPT3WINX64] only-windows -//@ [OPT3LINX64] only-x86_64 -//@ [OPT3WINX64] only-x86_64 -//@ min-llvm-version: 18.1.3 - -#![crate_type = "lib"] -#![no_std] - -// The code is from https://github.com/rust-lang/rust/issues/122805. -// Ensure we do not generate the shufflevector instruction -// to avoid complicating the code. -// CHECK-LABEL: define{{.*}}void @convert( -// CHECK-NOT: shufflevector -// OPT2: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 2 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 4 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 6 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 8 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 10 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 12 -// OPT2-NEXT: store i16 -// OPT2-NEXT: getelementptr inbounds{{( nuw)?}} i8, {{.+}} 14 -// OPT2-NEXT: store i16 -// OPT3LINX64: load <8 x i16> -// OPT3LINX64-NEXT: call <8 x i16> @llvm.bswap -// OPT3LINX64-NEXT: store <8 x i16> -// OPT3WINX64: load <8 x i16> -// OPT3WINX64-NEXT: call <8 x i16> @llvm.bswap -// OPT3WINX64-NEXT: store <8 x i16> -// CHECK-NEXT: ret void -#[no_mangle] -pub fn convert(value: [u16; 8]) -> [u8; 16] { - #[cfg(target_endian = "little")] - let bswap = u16::to_be; - #[cfg(target_endian = "big")] - let bswap = u16::to_le; - let addr16 = [ - bswap(value[0]), - bswap(value[1]), - bswap(value[2]), - bswap(value[3]), - bswap(value[4]), - bswap(value[5]), - bswap(value[6]), - bswap(value[7]), - ]; - unsafe { core::mem::transmute::<_, [u8; 16]>(addr16) } -} diff --git a/tests/codegen/issues/issue-13018.rs b/tests/codegen/issues/issue-13018.rs index a29452436d2c1..8040018b93106 100644 --- a/tests/codegen/issues/issue-13018.rs +++ b/tests/codegen/issues/issue-13018.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // A drop([...].clone()) sequence on an Rc should be a no-op // In particular, no call to __rust_dealloc should be emitted diff --git a/tests/codegen/issues/issue-27130.rs b/tests/codegen/issues/issue-27130.rs index 9c22b41e97fe3..594e02af0977f 100644 --- a/tests/codegen/issues/issue-27130.rs +++ b/tests/codegen/issues/issue-27130.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-34634.rs b/tests/codegen/issues/issue-34634.rs index a11f248e7404c..d32fa97ec38ce 100644 --- a/tests/codegen/issues/issue-34634.rs +++ b/tests/codegen/issues/issue-34634.rs @@ -3,7 +3,7 @@ // switch case (the second check present until rustc 1.12). // This test also verifies that a single panic call is generated (for the division by zero case). -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @f diff --git a/tests/codegen/issues/issue-34947-pow-i32.rs b/tests/codegen/issues/issue-34947-pow-i32.rs index c9141c0e92521..b4750cd35bc34 100644 --- a/tests/codegen/issues/issue-34947-pow-i32.rs +++ b/tests/codegen/issues/issue-34947-pow-i32.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-36010-some-box-is_some.rs b/tests/codegen/issues/issue-36010-some-box-is_some.rs index 44c01096f15ae..c9a8262162d65 100644 --- a/tests/codegen/issues/issue-36010-some-box-is_some.rs +++ b/tests/codegen/issues/issue-36010-some-box-is_some.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 use std::mem; diff --git a/tests/codegen/issues/issue-37945.rs b/tests/codegen/issues/issue-37945.rs index 01d1c694ec7c6..23d0eab8ae466 100644 --- a/tests/codegen/issues/issue-37945.rs +++ b/tests/codegen/issues/issue-37945.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled //@ ignore-32bit LLVM has a bug with them // Check that LLVM understands that `Iter` pointer is not null. Issue #37945. diff --git a/tests/codegen/issues/issue-45222.rs b/tests/codegen/issues/issue-45222.rs index d2c1ba421c45e..0201363c41aa6 100644 --- a/tests/codegen/issues/issue-45222.rs +++ b/tests/codegen/issues/issue-45222.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-45466.rs b/tests/codegen/issues/issue-45466.rs index 8a324fa555bb9..164a27ef5d4c4 100644 --- a/tests/codegen/issues/issue-45466.rs +++ b/tests/codegen/issues/issue-45466.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs b/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs index ea9288564e9d4..a48bb2a1ccf87 100644 --- a/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs +++ b/tests/codegen/issues/issue-45964-bounds-check-slice-pos.rs @@ -1,7 +1,7 @@ // This test case checks that slice::{r}position functions do not // prevent optimizing away bounds checks -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-59352.rs b/tests/codegen/issues/issue-59352.rs index 7bedc3ffc4a1c..cb4383d4a309d 100644 --- a/tests/codegen/issues/issue-59352.rs +++ b/tests/codegen/issues/issue-59352.rs @@ -6,7 +6,7 @@ // test case should be removed as it will become redundant. // mir-opt-level=3 enables inlining and enables LLVM to optimize away the unreachable panic call. -//@ compile-flags: -O -Z mir-opt-level=3 +//@ compile-flags: -Copt-level=3 -Z mir-opt-level=3 #![crate_type = "rlib"] diff --git a/tests/codegen/issues/issue-68667-unwrap-combinators.rs b/tests/codegen/issues/issue-68667-unwrap-combinators.rs index 21a5a5bf4ee94..7f4a32109fe9f 100644 --- a/tests/codegen/issues/issue-68667-unwrap-combinators.rs +++ b/tests/codegen/issues/issue-68667-unwrap-combinators.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // MIR inlining now optimizes this code. diff --git a/tests/codegen/issues/issue-69101-bounds-check.rs b/tests/codegen/issues/issue-69101-bounds-check.rs index c014a1c1b1d43..953b79aa263e8 100644 --- a/tests/codegen/issues/issue-69101-bounds-check.rs +++ b/tests/codegen/issues/issue-69101-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted in the loop when upfront slicing diff --git a/tests/codegen/issues/issue-73031.rs b/tests/codegen/issues/issue-73031.rs index db9c6d6db2336..80dea9b5bc2b5 100644 --- a/tests/codegen/issues/issue-73031.rs +++ b/tests/codegen/issues/issue-73031.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the unreachable `All::None` branch. diff --git a/tests/codegen/issues/issue-73258.rs b/tests/codegen/issues/issue-73258.rs index e5c622b5656b7..936a75544966b 100644 --- a/tests/codegen/issues/issue-73258.rs +++ b/tests/codegen/issues/issue-73258.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs index 9b3b1318ced12..1e2c25babe0a5 100644 --- a/tests/codegen/issues/issue-73396-bounds-check-after-position.rs +++ b/tests/codegen/issues/issue-73396-bounds-check-after-position.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Make sure no bounds checks are emitted when slicing or indexing diff --git a/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs b/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs index c3eb1a5968af4..e9dd0d1bf2378 100644 --- a/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs +++ b/tests/codegen/issues/issue-73827-bounds-check-index-in-subexpr.rs @@ -1,7 +1,7 @@ // This test checks that bounds checks are elided when // index is part of a (x | y) < C style condition -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-74938-array-split-at.rs b/tests/codegen/issues/issue-74938-array-split-at.rs index 2675e404ced3b..9d3e23d642b8a 100644 --- a/tests/codegen/issues/issue-74938-array-split-at.rs +++ b/tests/codegen/issues/issue-74938-array-split-at.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75525-bounds-checks.rs b/tests/codegen/issues/issue-75525-bounds-checks.rs index fbc10ce3d843e..5dfbd35001010 100644 --- a/tests/codegen/issues/issue-75525-bounds-checks.rs +++ b/tests/codegen/issues/issue-75525-bounds-checks.rs @@ -1,6 +1,6 @@ // Regression test for #75525, verifies that no bounds checks are generated. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75546.rs b/tests/codegen/issues/issue-75546.rs index 1132c8ab5093e..1e1e6543a889c 100644 --- a/tests/codegen/issues/issue-75546.rs +++ b/tests/codegen/issues/issue-75546.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the impossible `i == 0` check. diff --git a/tests/codegen/issues/issue-75659.rs b/tests/codegen/issues/issue-75659.rs index 1860b73f2a9ad..0960bfdb6b0aa 100644 --- a/tests/codegen/issues/issue-75659.rs +++ b/tests/codegen/issues/issue-75659.rs @@ -1,7 +1,7 @@ // This test checks that the call to memchr/slice_contains is optimized away // when searching in small slices. -//@ compile-flags: -O -Zinline-mir=false +//@ compile-flags: -Copt-level=3 -Zinline-mir=false //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-75978.rs b/tests/codegen/issues/issue-75978.rs index ed953fae76715..f4b0bc36329eb 100644 --- a/tests/codegen/issues/issue-75978.rs +++ b/tests/codegen/issues/issue-75978.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-77812.rs b/tests/codegen/issues/issue-77812.rs index bf84ac21b16d8..09e2376c30dda 100644 --- a/tests/codegen/issues/issue-77812.rs +++ b/tests/codegen/issues/issue-77812.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // Test that LLVM can eliminate the unreachable `Variant::Zero` branch. diff --git a/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs b/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs index 49301be776fdb..4023412f23cff 100644 --- a/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs +++ b/tests/codegen/issues/issue-81408-dllimport-thinlto-windows.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C lto=thin -C prefer-dynamic=no +//@ compile-flags: -Copt-level=3 -C lto=thin -C prefer-dynamic=no //@ only-windows //@ aux-build:static_dllimport_aux.rs diff --git a/tests/codegen/issues/issue-84268.rs b/tests/codegen/issues/issue-84268.rs index 5e852133ed3d8..8a8ea9d1ccf8f 100644 --- a/tests/codegen/issues/issue-84268.rs +++ b/tests/codegen/issues/issue-84268.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O --crate-type=rlib +//@ compile-flags: -Copt-level=3 --crate-type=rlib #![feature(intrinsics, repr_simd)] extern "rust-intrinsic" { diff --git a/tests/codegen/issues/issue-85872-multiple-reverse.rs b/tests/codegen/issues/issue-85872-multiple-reverse.rs index fb5ff8309e5c5..6f566ddee6b02 100644 --- a/tests/codegen/issues/issue-85872-multiple-reverse.rs +++ b/tests/codegen/issues/issue-85872-multiple-reverse.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs b/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs index a8fab61b13e92..345c09738b610 100644 --- a/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs +++ b/tests/codegen/issues/issue-86109-eliminate-div-by-zero-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //! Test for https://github.com/rust-lang/rust/issues/86109 //! Check LLVM can eliminate the impossible division by zero check by //! ensuring there is no call (to panic) instruction. diff --git a/tests/codegen/issues/issue-93036-assert-index.rs b/tests/codegen/issues/issue-93036-assert-index.rs index 7a2ea08726688..46f45c2f06ee7 100644 --- a/tests/codegen/issues/issue-93036-assert-index.rs +++ b/tests/codegen/issues/issue-93036-assert-index.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96274.rs b/tests/codegen/issues/issue-96274.rs index ffefd5f43f8ca..2425ec53e4e19 100644 --- a/tests/codegen/issues/issue-96274.rs +++ b/tests/codegen/issues/issue-96274.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs index f922462cc2790..dce156dd42541 100644 --- a/tests/codegen/issues/issue-96497-slice-size-nowrap.rs +++ b/tests/codegen/issues/issue-96497-slice-size-nowrap.rs @@ -2,7 +2,7 @@ // The possibility of wrapping results in an additional branch when dropping boxed slices // in some situations, see https://github.com/rust-lang/rust/issues/96497#issuecomment-1112865218 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs b/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs index 28324bfa90ef3..aecb81caf22b1 100644 --- a/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs +++ b/tests/codegen/issues/issue-98156-const-arg-temp-lifetime.rs @@ -1,6 +1,6 @@ // This test checks that temporaries for indirectly-passed arguments get lifetime markers. -//@ compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs index 40827e32a0124..76adcf9fd4530 100644 --- a/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs +++ b/tests/codegen/issues/issue-98294-get-mut-copy-from-slice-opt.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/issues/issue-99960.rs b/tests/codegen/issues/issue-99960.rs index 9029121d35f49..571a9be967d49 100644 --- a/tests/codegen/issues/issue-99960.rs +++ b/tests/codegen/issues/issue-99960.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/layout-size-checks.rs b/tests/codegen/layout-size-checks.rs index 901f8f822f320..d64a7055e0b1e 100644 --- a/tests/codegen/layout-size-checks.rs +++ b/tests/codegen/layout-size-checks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/lib-optimizations/iter-sum.rs b/tests/codegen/lib-optimizations/iter-sum.rs index ea8c916bfc1b2..a054ffffe74bd 100644 --- a/tests/codegen/lib-optimizations/iter-sum.rs +++ b/tests/codegen/lib-optimizations/iter-sum.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 (vectorization varies between architectures) #![crate_type = "lib"] diff --git a/tests/codegen/lib-optimizations/slice_rotate.rs b/tests/codegen/lib-optimizations/slice_rotate.rs index d0a7b328d1845..aa4bb3b528c96 100644 --- a/tests/codegen/lib-optimizations/slice_rotate.rs +++ b/tests/codegen/lib-optimizations/slice_rotate.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/lifetime_start_end.rs b/tests/codegen/lifetime_start_end.rs index 99d37c25dcac7..0639e7640aa15 100644 --- a/tests/codegen/lifetime_start_end.rs +++ b/tests/codegen/lifetime_start_end.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Zmir-opt-level=0 +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Zmir-opt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen/loads.rs b/tests/codegen/loads.rs index e3e2f7577706b..88d67642b7250 100644 --- a/tests/codegen/loads.rs +++ b/tests/codegen/loads.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -O +//@ compile-flags: -C no-prepopulate-passes -Zmir-opt-level=0 -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs index b147d01b38e32..b11bd657c18ec 100644 --- a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu //@ needs-llvm-components: loongarch #![feature(no_core, lang_items)] diff --git a/tests/codegen/lto-removes-invokes.rs b/tests/codegen/lto-removes-invokes.rs index 3217c239bf789..3640bd1ab8652 100644 --- a/tests/codegen/lto-removes-invokes.rs +++ b/tests/codegen/lto-removes-invokes.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C lto -C panic=abort -O +//@ compile-flags: -C lto -C panic=abort -Copt-level=3 //@ no-prefer-dynamic fn main() { diff --git a/tests/codegen/macos/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs index 389434da1f67d..1f44bdfc6485e 100644 --- a/tests/codegen/macos/i686-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. -//@ compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs index 4c6b7656e5937..a09773e0b9e26 100644 --- a/tests/codegen/macos/i686-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-no-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. -//@ compile-flags: -O --target=i686-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs index a40deca24bbeb..bd8c027a9fb9d 100644 --- a/tests/codegen/macos/x86_64-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. -//@ compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] diff --git a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs index 26d519ef1a6dc..ff4a8fc46f984 100644 --- a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs @@ -2,7 +2,7 @@ // Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. -//@ compile-flags: -O --target=x86_64-apple-darwin --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] diff --git a/tests/codegen/match-optimized.rs b/tests/codegen/match-optimized.rs index d6893be0b7bef..7b409e619a8c5 100644 --- a/tests/codegen/match-optimized.rs +++ b/tests/codegen/match-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -O +//@ compile-flags: -Cno-prepopulate-passes -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/match-optimizes-away.rs b/tests/codegen/match-optimizes-away.rs index 82ab5718b3750..8a70d99342316 100644 --- a/tests/codegen/match-optimizes-away.rs +++ b/tests/codegen/match-optimizes-away.rs @@ -1,5 +1,5 @@ // -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] pub enum Three { diff --git a/tests/codegen/maybeuninit-rvo.rs b/tests/codegen/maybeuninit-rvo.rs index db2e33c34bd25..097aa610f1b34 100644 --- a/tests/codegen/maybeuninit-rvo.rs +++ b/tests/codegen/maybeuninit-rvo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-unwind #![feature(c_unwind)] #![crate_type = "lib"] diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 41c3660dc15c0..9f3c6bacb712c 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ only-x86_64 (to not worry about usize differing) //@ ignore-std-debug-assertions // Reason: precondition checks make mem::replace not a candidate for MIR inlining diff --git a/tests/codegen/merge-functions.rs b/tests/codegen/merge-functions.rs index 8e4b65c9ee65c..b9d3727ce112e 100644 --- a/tests/codegen/merge-functions.rs +++ b/tests/codegen/merge-functions.rs @@ -1,6 +1,6 @@ //@ revisions: O Os //@[Os] compile-flags: -Copt-level=s -//@[O] compile-flags: -O +//@[O] compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK: @func{{2|1}} = {{.*}}alias{{.*}}@func{{1|2}} diff --git a/tests/codegen/mir-aggregate-no-alloca.rs b/tests/codegen/mir-aggregate-no-alloca.rs index 37b024a55b373..77d367ed5da9e 100644 --- a/tests/codegen/mir-aggregate-no-alloca.rs +++ b/tests/codegen/mir-aggregate-no-alloca.rs @@ -2,7 +2,7 @@ //@ revisions: bit32 bit64 //@[bit32] only-32bit //@[bit64] only-64bit -//@ compile-flags: -O -C no-prepopulate-passes -Z randomize-layout=no +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z randomize-layout=no #![crate_type = "lib"] diff --git a/tests/codegen/mir-inlined-line-numbers.rs b/tests/codegen/mir-inlined-line-numbers.rs index 57978bc709765..cfe43a6cf89ac 100644 --- a/tests/codegen/mir-inlined-line-numbers.rs +++ b/tests/codegen/mir-inlined-line-numbers.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -g +//@ compile-flags: -Copt-level=3 -g #![crate_type = "lib"] diff --git a/tests/codegen/move-before-nocapture-ref-arg.rs b/tests/codegen/move-before-nocapture-ref-arg.rs index c3448192ea173..2ebd645e1c3d0 100644 --- a/tests/codegen/move-before-nocapture-ref-arg.rs +++ b/tests/codegen/move-before-nocapture-ref-arg.rs @@ -1,6 +1,6 @@ // Verify that move before the call of the function with noalias, nocapture, readonly. // #107436 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/move-operands.rs b/tests/codegen/move-operands.rs index 4f22921b4a3dc..ddad231b762cd 100644 --- a/tests/codegen/move-operands.rs +++ b/tests/codegen/move-operands.rs @@ -1,5 +1,5 @@ // Verify that optimized MIR only copies `a` once. -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/naked-fn/generics.rs b/tests/codegen/naked-fn/generics.rs index a33d213617a8b..64998df64ddb6 100644 --- a/tests/codegen/naked-fn/generics.rs +++ b/tests/codegen/naked-fn/generics.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/noalias-box-off.rs b/tests/codegen/noalias-box-off.rs index 1642103903a0b..664c79502804e 100644 --- a/tests/codegen/noalias-box-off.rs +++ b/tests/codegen/noalias-box-off.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z box-noalias=no +//@ compile-flags: -Copt-level=3 -Z box-noalias=no #![crate_type = "lib"] diff --git a/tests/codegen/noalias-box.rs b/tests/codegen/noalias-box.rs index 06f94691c8956..cccde775977a1 100644 --- a/tests/codegen/noalias-box.rs +++ b/tests/codegen/noalias-box.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/noalias-flag.rs b/tests/codegen/noalias-flag.rs index 35b94d813d5fb..67ba68ee6f80a 100644 --- a/tests/codegen/noalias-flag.rs +++ b/tests/codegen/noalias-flag.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmutable-noalias=no +//@ compile-flags: -Copt-level=3 -Zmutable-noalias=no #![crate_type = "lib"] diff --git a/tests/codegen/noalias-refcell.rs b/tests/codegen/noalias-refcell.rs index 51d13967bece6..b37adf92b9cc3 100644 --- a/tests/codegen/noalias-refcell.rs +++ b/tests/codegen/noalias-refcell.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/noalias-rwlockreadguard.rs b/tests/codegen/noalias-rwlockreadguard.rs index 7b870cb28b4fc..c676dc32399da 100644 --- a/tests/codegen/noalias-rwlockreadguard.rs +++ b/tests/codegen/noalias-rwlockreadguard.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/noalias-unpin.rs b/tests/codegen/noalias-unpin.rs index 630a62020c11d..30a8b399b9798 100644 --- a/tests/codegen/noalias-unpin.rs +++ b/tests/codegen/noalias-unpin.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z mutable-noalias=yes +//@ compile-flags: -Copt-level=3 -Z mutable-noalias=yes #![crate_type = "lib"] diff --git a/tests/codegen/nonzero-type-not-zero-on-get.rs b/tests/codegen/nonzero-type-not-zero-on-get.rs new file mode 100644 index 0000000000000..313797a15dfca --- /dev/null +++ b/tests/codegen/nonzero-type-not-zero-on-get.rs @@ -0,0 +1,20 @@ +//@ compile-flags: -C opt-level=3 +//! Ensure that `.get()` on `std::num::NonZero*` types do not +//! check for zero equivalency. +//! Discovered in issue #49572. + +#![crate_type = "lib"] + +#[no_mangle] +pub fn foo(x: std::num::NonZeroU32) -> bool { + // CHECK-LABEL: @foo( + // CHECK: ret i1 true + x.get() != 0 +} + +#[no_mangle] +pub fn bar(x: std::num::NonZeroI64) -> bool { + // CHECK-LABEL: @bar( + // CHECK: ret i1 true + x.get() != 0 +} diff --git a/tests/codegen/nrvo.rs b/tests/codegen/nrvo.rs index aa8bed941f545..7972186bfe5d1 100644 --- a/tests/codegen/nrvo.rs +++ b/tests/codegen/nrvo.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/option-as-slice.rs b/tests/codegen/option-as-slice.rs index 0edbbac11762d..39b34a2035b74 100644 --- a/tests/codegen/option-as-slice.rs +++ b/tests/codegen/option-as-slice.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z randomize-layout=no +//@ compile-flags: -Copt-level=3 -Z randomize-layout=no //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/option-niche-eq.rs b/tests/codegen/option-niche-eq.rs index caef0598b4bed..9c5ed9ce57a5e 100644 --- a/tests/codegen/option-niche-eq.rs +++ b/tests/codegen/option-niche-eq.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] extern crate core; diff --git a/tests/codegen/packed.rs b/tests/codegen/packed.rs index 66df978d48ca2..6f62719282eac 100644 --- a/tests/codegen/packed.rs +++ b/tests/codegen/packed.rs @@ -1,5 +1,5 @@ // -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/panic-abort-windows.rs b/tests/codegen/panic-abort-windows.rs index eb61e649f04a2..17fdd9cc72609 100644 --- a/tests/codegen/panic-abort-windows.rs +++ b/tests/codegen/panic-abort-windows.rs @@ -1,7 +1,7 @@ // This test is for *-windows only. //@ only-windows -//@ compile-flags: -C no-prepopulate-passes -C panic=abort -O +//@ compile-flags: -C no-prepopulate-passes -C panic=abort -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/panic-in-drop-abort.rs b/tests/codegen/panic-in-drop-abort.rs index b150c537ad550..e89170e56ed08 100644 --- a/tests/codegen/panic-in-drop-abort.rs +++ b/tests/codegen/panic-in-drop-abort.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z panic-in-drop=abort -O +//@ compile-flags: -Z panic-in-drop=abort -Copt-level=3 //@ ignore-msvc // Ensure that unwinding code paths are eliminated from the output after diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 828af05436b42..cd81db6395349 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -1,7 +1,7 @@ //@ ignore-msvc //@ needs-unwind -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/placement-new.rs b/tests/codegen/placement-new.rs index 0ec2b6a6f20e7..7f7f0033bece3 100644 --- a/tests/codegen/placement-new.rs +++ b/tests/codegen/placement-new.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ compile-flags: -Zmerge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/ptr-arithmetic.rs b/tests/codegen/ptr-arithmetic.rs index 6f115d33d8ddf..ecb44b30f5cad 100644 --- a/tests/codegen/ptr-arithmetic.rs +++ b/tests/codegen/ptr-arithmetic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/ptr-read-metadata.rs b/tests/codegen/ptr-read-metadata.rs index e3565c962f738..b38cfdbff8835 100644 --- a/tests/codegen/ptr-read-metadata.rs +++ b/tests/codegen/ptr-read-metadata.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/range-attribute.rs b/tests/codegen/range-attribute.rs index a44ec1026b164..e23f5e6bb748a 100644 --- a/tests/codegen/range-attribute.rs +++ b/tests/codegen/range-attribute.rs @@ -5,7 +5,7 @@ //@ revisions: bit32 bit64 //@[bit32] only-32bit //@[bit64] only-64bit -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/range_to_inclusive.rs b/tests/codegen/range_to_inclusive.rs index f3001897f88d9..6d939f40f5582 100644 --- a/tests/codegen/range_to_inclusive.rs +++ b/tests/codegen/range_to_inclusive.rs @@ -1,6 +1,6 @@ //! Test that `RangeTo` and `RangeToInclusive` generate identical //! (and optimal) code; #63646 -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/reg-struct-return.rs b/tests/codegen/reg-struct-return.rs index 73816745ea86d..dfc9f8c519c2a 100644 --- a/tests/codegen/reg-struct-return.rs +++ b/tests/codegen/reg-struct-return.rs @@ -5,7 +5,7 @@ //@ revisions: ENABLED DISABLED //@ add-core-stubs -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ [ENABLED] compile-flags: -Zreg-struct-return //@ needs-llvm-components: x86 diff --git a/tests/codegen/regparm-inreg.rs b/tests/codegen/regparm-inreg.rs index c8c647bcc87c0..82e157311287a 100644 --- a/tests/codegen/regparm-inreg.rs +++ b/tests/codegen/regparm-inreg.rs @@ -2,7 +2,7 @@ // marks function arguments as "inreg" like the C/C++ compilers for the platforms. // x86 only. -//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 //@ revisions:regparm0 regparm1 regparm2 regparm3 diff --git a/tests/codegen/repeat-trusted-len.rs b/tests/codegen/repeat-trusted-len.rs index fa01f2b4969d6..95379535971f2 100644 --- a/tests/codegen/repeat-trusted-len.rs +++ b/tests/codegen/repeat-trusted-len.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 // #![crate_type = "lib"] diff --git a/tests/codegen/repr/transparent-byval-struct-ptr.rs b/tests/codegen/repr/transparent-byval-struct-ptr.rs index 92ef937d734b4..f9cfeb90390c9 100644 --- a/tests/codegen/repr/transparent-byval-struct-ptr.rs +++ b/tests/codegen/repr/transparent-byval-struct-ptr.rs @@ -1,5 +1,5 @@ //@ revisions: i686-linux i686-freebsd x64-linux x64-apple -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[i686-linux] compile-flags: --target i686-unknown-linux-gnu //@[i686-linux] needs-llvm-components: x86 diff --git a/tests/codegen/repr/transparent-imm-array.rs b/tests/codegen/repr/transparent-imm-array.rs index 99828e4e80a5f..f790d093cf4a8 100644 --- a/tests/codegen/repr/transparent-imm-array.rs +++ b/tests/codegen/repr/transparent-imm-array.rs @@ -1,5 +1,5 @@ //@ revisions: arm-linux arm-android armv7-linux armv7-android mips thumb sparc -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[arm-linux] compile-flags: --target arm-unknown-linux-gnueabi //@[arm-linux] needs-llvm-components: arm diff --git a/tests/codegen/repr/transparent-mips64.rs b/tests/codegen/repr/transparent-mips64.rs index 588d440b4d7bf..7282654b8562d 100644 --- a/tests/codegen/repr/transparent-mips64.rs +++ b/tests/codegen/repr/transparent-mips64.rs @@ -1,5 +1,5 @@ //@ revisions: mips64 mips64el -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 //@[mips64] needs-llvm-components: mips diff --git a/tests/codegen/repr/transparent-opaque-ptr.rs b/tests/codegen/repr/transparent-opaque-ptr.rs index 29c03f0d5d96f..798b7e01bba5b 100644 --- a/tests/codegen/repr/transparent-opaque-ptr.rs +++ b/tests/codegen/repr/transparent-opaque-ptr.rs @@ -1,5 +1,5 @@ //@ revisions: aarch64-linux aarch64-darwin wasm32-wasip1 -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu //@[aarch64-linux] needs-llvm-components: aarch64 diff --git a/tests/codegen/repr/transparent-sparc64.rs b/tests/codegen/repr/transparent-sparc64.rs index 8e4c8ce2ee9b1..05c090bd67215 100644 --- a/tests/codegen/repr/transparent-sparc64.rs +++ b/tests/codegen/repr/transparent-sparc64.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target sparc64-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target sparc64-unknown-linux-gnu //@ needs-llvm-components: sparc // See ./transparent.rs diff --git a/tests/codegen/repr/transparent-sysv64.rs b/tests/codegen/repr/transparent-sysv64.rs index 068414976c523..99c855db96200 100644 --- a/tests/codegen/repr/transparent-sysv64.rs +++ b/tests/codegen/repr/transparent-sysv64.rs @@ -1,5 +1,5 @@ //@ revisions: linux apple win -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@[linux] compile-flags: --target x86_64-unknown-linux-gnu //@[linux] needs-llvm-components: x86 diff --git a/tests/codegen/repr/transparent.rs b/tests/codegen/repr/transparent.rs index adcd3aacd2ace..e7e4c40a09917 100644 --- a/tests/codegen/repr/transparent.rs +++ b/tests/codegen/repr/transparent.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ ignore-riscv64 riscv64 has an i128 type used with test_Vector //@ ignore-s390x s390x with default march passes vector types per reference //@ ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index 520192b5d5915..46f747ad40750 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: --target riscv64gc-unknown-linux-gnu -O -C no-prepopulate-passes -C panic=abort +//@ compile-flags: --target riscv64gc-unknown-linux-gnu -Copt-level=3 -C no-prepopulate-passes -C panic=abort //@ needs-llvm-components: riscv #![crate_type = "lib"] diff --git a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs index c14d5c01450bc..bef8fe0c04418 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv #![feature(no_core, lang_items)] diff --git a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs index 27018d2e6d203..214370f424c25 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv #![feature(no_core, lang_items)] diff --git a/tests/codegen/rust-abi-arch-specific-adjustment.rs b/tests/codegen/rust-abi-arch-specific-adjustment.rs index 9da10f662b0e6..561f081c700ea 100644 --- a/tests/codegen/rust-abi-arch-specific-adjustment.rs +++ b/tests/codegen/rust-abi-arch-specific-adjustment.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes //@ revisions: riscv64 loongarch64 //@[riscv64] only-riscv64 diff --git a/tests/codegen/s390x-simd.rs b/tests/codegen/s390x-simd.rs index 23181e6a10308..ac39357519e4c 100644 --- a/tests/codegen/s390x-simd.rs +++ b/tests/codegen/s390x-simd.rs @@ -1,7 +1,7 @@ //! test that s390x vector types are passed using `PassMode::Direct` //! see also https://github.com/rust-lang/rust/issues/135744 //@ add-core-stubs -//@ compile-flags: --target s390x-unknown-linux-gnu -O +//@ compile-flags: --target s390x-unknown-linux-gnu -Copt-level=3 //@ needs-llvm-components: systemz #![crate_type = "rlib"] diff --git a/tests/codegen/scalar-pair-bool.rs b/tests/codegen/scalar-pair-bool.rs index fce0648e45074..def3b32f71aa4 100644 --- a/tests/codegen/scalar-pair-bool.rs +++ b/tests/codegen/scalar-pair-bool.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index 75f989d6e12c4..bf779e7b1c915 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -38,7 +38,7 @@ pub fn build_array_s(x: [f32; 4]) -> S<4> { #[no_mangle] pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> { // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: ret <4 x float> %[[VAL:.+]] unsafe { std::mem::transmute(x) } } @@ -53,6 +53,6 @@ pub fn build_array_t(x: [f32; 4]) -> T { #[no_mangle] pub fn build_array_transmute_t(x: [f32; 4]) -> T { // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: ret <4 x float> %[[VAL:.+]] unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/simd/packed-simd.rs b/tests/codegen/simd/packed-simd.rs index 1df09c96e6cc0..a27d5e3af452a 100644 --- a/tests/codegen/simd/packed-simd.rs +++ b/tests/codegen/simd/packed-simd.rs @@ -1,4 +1,5 @@ //@ revisions:opt3 noopt +//@ only-x86_64 //@[opt3] compile-flags: -Copt-level=3 //@[noopt] compile-flags: -Cno-prepopulate-passes @@ -14,14 +15,14 @@ use core::{mem, ptr}; #[repr(simd, packed)] #[derive(Copy, Clone)] -pub struct Simd([T; N]); +pub struct PackedSimd([T; N]); #[repr(simd)] #[derive(Copy, Clone)] pub struct FullSimd([T; N]); // non-powers-of-two have padding and need to be expanded to full vectors -fn load(v: Simd) -> FullSimd { +fn load(v: PackedSimd) -> FullSimd { unsafe { let mut tmp = mem::MaybeUninit::>::uninit(); ptr::copy_nonoverlapping(&v as *const _, tmp.as_mut_ptr().cast(), 1); @@ -29,18 +30,16 @@ fn load(v: Simd) -> FullSimd { } } -// CHECK-LABEL: square_packed_full -// CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align (8|16)]]{{[^%]*}} [[RET_VREG:%[_0-9]*]] -// CHECK-SAME: ptr{{[a-z_ ]*}} align 4 +// CHECK-LABEL: define <3 x float> @square_packed_full(ptr{{[a-z_ ]*}} align 4 {{[^,]*}}) #[no_mangle] -pub fn square_packed_full(x: Simd) -> FullSimd { - // CHECK-NEXT: start - // noopt: alloca [[RET_TYPE]], [[RET_ALIGN]] - // CHECK: load <3 x float> +pub fn square_packed_full(x: PackedSimd) -> FullSimd { + // The unoptimized version of this is not very interesting to check + // since `load` does not get inlined. + // opt3-NEXT: start: + // opt3-NEXT: load <3 x float> let x = load(x); - // CHECK: [[VREG:%[a-z0-9_]+]] = fmul <3 x float> - // CHECK-NEXT: store <3 x float> [[VREG]], ptr [[RET_VREG]], [[RET_ALIGN]] - // CHECK-NEXT: ret void + // opt3-NEXT: [[VREG:%[a-z0-9_]+]] = fmul <3 x float> + // opt3-NEXT: ret <3 x float> [[VREG:%[a-z0-9_]+]] unsafe { intrinsics::simd_mul(x, x) } } @@ -48,7 +47,7 @@ pub fn square_packed_full(x: Simd) -> FullSimd { // CHECK-SAME: ptr{{[a-z_ ]*}} sret([[RET_TYPE:[^)]+]]) [[RET_ALIGN:align 4]]{{[^%]*}} [[RET_VREG:%[_0-9]*]] // CHECK-SAME: ptr{{[a-z_ ]*}} align 4 #[no_mangle] -pub fn square_packed(x: Simd) -> Simd { +pub fn square_packed(x: PackedSimd) -> PackedSimd { // CHECK-NEXT: start // CHECK-NEXT: load <3 x float> // noopt-NEXT: load <3 x float> diff --git a/tests/codegen/simd/swap-simd-types.rs b/tests/codegen/simd/swap-simd-types.rs index cd6e84286e1c9..69767d0a75580 100644 --- a/tests/codegen/simd/swap-simd-types.rs +++ b/tests/codegen/simd/swap-simd-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C target-feature=+avx +//@ compile-flags: -Copt-level=3 -C target-feature=+avx //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/slice-as_chunks.rs b/tests/codegen/slice-as_chunks.rs index 631d18d780951..a90ee7c628ece 100644 --- a/tests/codegen/slice-as_chunks.rs +++ b/tests/codegen/slice-as_chunks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/slice-indexing.rs b/tests/codegen/slice-indexing.rs index 75112bb0c24e5..d957ccfb5ef7d 100644 --- a/tests/codegen/slice-indexing.rs +++ b/tests/codegen/slice-indexing.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because the LLVM type of i64 for usize shows up) #![crate_type = "lib"] diff --git a/tests/codegen/slice-iter-fold.rs b/tests/codegen/slice-iter-fold.rs index 1770cd4a11994..55ab34661c36e 100644 --- a/tests/codegen/slice-iter-fold.rs +++ b/tests/codegen/slice-iter-fold.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] // CHECK-LABEL: @slice_fold_to_last diff --git a/tests/codegen/slice-iter-len-eq-zero.rs b/tests/codegen/slice-iter-len-eq-zero.rs index b2a4b2495b6a2..c85861d47f852 100644 --- a/tests/codegen/slice-iter-len-eq-zero.rs +++ b/tests/codegen/slice-iter-len-eq-zero.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] type Demo = [u8; 3]; diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs index 307020b42c06f..98a1b961a6443 100644 --- a/tests/codegen/slice-iter-nonnull.rs +++ b/tests/codegen/slice-iter-nonnull.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-deterministic-layouts #![crate_type = "lib"] #![feature(exact_size_is_empty)] diff --git a/tests/codegen/slice-pointer-nonnull-unwrap.rs b/tests/codegen/slice-pointer-nonnull-unwrap.rs index 202edb98c7329..35e4bf2c6615f 100644 --- a/tests/codegen/slice-pointer-nonnull-unwrap.rs +++ b/tests/codegen/slice-pointer-nonnull-unwrap.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] use std::ptr::NonNull; diff --git a/tests/codegen/slice-position-bounds-check.rs b/tests/codegen/slice-position-bounds-check.rs index f83e2f2ec440e..0d1d1d869ae25 100644 --- a/tests/codegen/slice-position-bounds-check.rs +++ b/tests/codegen/slice-position-bounds-check.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C panic=abort +//@ compile-flags: -Copt-level=3 -C panic=abort #![crate_type = "lib"] fn search(arr: &mut [T], a: &T) -> Result { diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 1153d7817b278..a5046a7594458 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] use std::num::NonZero; diff --git a/tests/codegen/slice-reverse.rs b/tests/codegen/slice-reverse.rs index 87cdad479628a..e58d1c1d9d8ea 100644 --- a/tests/codegen/slice-reverse.rs +++ b/tests/codegen/slice-reverse.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 //@ ignore-std-debug-assertions (debug assertions prevent generating shufflevector) diff --git a/tests/codegen/slice-windows-no-bounds-check.rs b/tests/codegen/slice-windows-no-bounds-check.rs index db3211c8defdb..87e89b14f06c8 100644 --- a/tests/codegen/slice-windows-no-bounds-check.rs +++ b/tests/codegen/slice-windows-no-bounds-check.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 use std::slice::Windows; diff --git a/tests/codegen/slice_as_from_ptr_range.rs b/tests/codegen/slice_as_from_ptr_range.rs index 47c60461c0e81..2073f05c07f0c 100644 --- a/tests/codegen/slice_as_from_ptr_range.rs +++ b/tests/codegen/slice_as_from_ptr_range.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit (because we're using [ui]size) #![crate_type = "lib"] diff --git a/tests/codegen/some-global-nonnull.rs b/tests/codegen/some-global-nonnull.rs index 8e9308a726582..bb4d12e1c7621 100644 --- a/tests/codegen/some-global-nonnull.rs +++ b/tests/codegen/some-global-nonnull.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/sparc-struct-abi.rs b/tests/codegen/sparc-struct-abi.rs index 5d9781663570a..0a8720c4fcae3 100644 --- a/tests/codegen/sparc-struct-abi.rs +++ b/tests/codegen/sparc-struct-abi.rs @@ -1,7 +1,7 @@ // Checks that we correctly codegen extern "C" functions returning structs. // See issues #52638 and #86163. -//@ compile-flags: -O --target=sparc64-unknown-linux-gnu --crate-type=rlib +//@ compile-flags: -Copt-level=3 --target=sparc64-unknown-linux-gnu --crate-type=rlib //@ needs-llvm-components: sparc #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/codegen/static-relocation-model-msvc.rs b/tests/codegen/static-relocation-model-msvc.rs index 8ed8331466c73..4d30e6ec505d4 100644 --- a/tests/codegen/static-relocation-model-msvc.rs +++ b/tests/codegen/static-relocation-model-msvc.rs @@ -1,6 +1,6 @@ // Verify linkage of external symbols in the static relocation model on MSVC. // -//@ compile-flags: -O -C relocation-model=static +//@ compile-flags: -Copt-level=3 -C relocation-model=static //@ aux-build: extern_decl.rs //@ only-x86_64-pc-windows-msvc diff --git a/tests/codegen/step_by-overflow-checks.rs b/tests/codegen/step_by-overflow-checks.rs index 43e8514a8b7c2..53800e9f879d9 100644 --- a/tests/codegen/step_by-overflow-checks.rs +++ b/tests/codegen/step_by-overflow-checks.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/swap-large-types.rs b/tests/codegen/swap-large-types.rs index 761d48969dad9..49a41bb14692f 100644 --- a/tests/codegen/swap-large-types.rs +++ b/tests/codegen/swap-large-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/swap-small-types.rs b/tests/codegen/swap-small-types.rs index 1a48c63d8139f..76bb853e64238 100644 --- a/tests/codegen/swap-small-types.rs +++ b/tests/codegen/swap-small-types.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs index 3cd81652f5ace..9ce34473b9150 100644 --- a/tests/codegen/thread-local.rs +++ b/tests/codegen/thread-local.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ aux-build:thread_local_aux.rs //@ ignore-windows FIXME(#134939) //@ ignore-wasm globals are used instead of thread locals diff --git a/tests/codegen/to_vec.rs b/tests/codegen/to_vec.rs index 4666f8d6f1532..4f6e77188d81b 100644 --- a/tests/codegen/to_vec.rs +++ b/tests/codegen/to_vec.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/trailing_zeros.rs b/tests/codegen/trailing_zeros.rs index b659e061821ea..0816a98099269 100644 --- a/tests/codegen/trailing_zeros.rs +++ b/tests/codegen/trailing_zeros.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/transmute-optimized.rs b/tests/codegen/transmute-optimized.rs index de54eecf0c049..477fdc6de90d4 100644 --- a/tests/codegen/transmute-optimized.rs +++ b/tests/codegen/transmute-optimized.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // This tests that LLVM can optimize based on the niches in the source or diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index 36a0d9066c895..751d7ca931160 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled --edition=2021 +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled --edition=2021 //@ only-x86_64 // FIXME: Remove the `min-llvm-version`. //@ revisions: NINETEEN TWENTY diff --git a/tests/codegen/ub-checks.rs b/tests/codegen/ub-checks.rs index de48d74e652f1..67f5bff08d5bb 100644 --- a/tests/codegen/ub-checks.rs +++ b/tests/codegen/ub-checks.rs @@ -8,7 +8,7 @@ //@ revisions: DEBUG NOCHECKS //@ [DEBUG] compile-flags: //@ [NOCHECKS] compile-flags: -Zub-checks=no -//@ compile-flags: -O -Cdebug-assertions=yes +//@ compile-flags: -Copt-level=3 -Cdebug-assertions=yes #![crate_type = "lib"] diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs index 86517c896276d..b27eb73c0cc94 100644 --- a/tests/codegen/unchecked_shifts.rs +++ b/tests/codegen/unchecked_shifts.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(unchecked_shifts)] diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index 2f14682dfa57c..92d40d8ac14cb 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -1,5 +1,5 @@ //@ ignore-emscripten vectors passed directly -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes // 32-bit x86 returns `f32` differently to avoid the x87 stack. // 32-bit systems will return 128bit values using a return area pointer. //@ revisions: x86 bit32 bit64 diff --git a/tests/codegen/unreachable-branch-not-generated.rs b/tests/codegen/unreachable-branch-not-generated.rs new file mode 100644 index 0000000000000..0c01ede2f4a83 --- /dev/null +++ b/tests/codegen/unreachable-branch-not-generated.rs @@ -0,0 +1,41 @@ +//@ compile-flags: -C opt-level=3 +//! Ensure that matching on `x % 5` generates an unreachable +//! branch for values greater than 4. +//! Discovered in issue #93514. + +#![crate_type = "lib"] + +#[no_mangle] +pub unsafe fn parse0(x: u32) -> u32 { + // CHECK-LABEL: i32 @parse0( + // CHECK-SAME: i32 noundef [[X:%.*]]) + // CHECK-NEXT: [[START:.*:]] + // CHECK-NEXT: [[_2:%.*]] = urem i32 [[X]], 5 + // CHECK-NEXT: switch i32 [[_2]], label %[[DEFAULT_UNREACHABLE1:.*]] [ + // CHECK-NEXT: i32 0, label %[[BB6:.*]] + // CHECK-NEXT: i32 1, label %[[BB5:.*]] + // CHECK-NEXT: i32 2, label %[[BB4:.*]] + // CHECK-NEXT: i32 3, label %[[BB3:.*]] + // CHECK-NEXT: i32 4, label %[[BB2:.*]] + // CHECK-NEXT: ] + // CHECK: [[DEFAULT_UNREACHABLE1]]: + // CHECK-NEXT: unreachable + // CHECK: ret i32 + match x % 5 { + 0 => f1(x), + 1 => f2(x), + 2 => f3(x), + 3 => f4(x), + 4 => f5(x), + _ => eliminate_me(), + } +} + +extern "Rust" { + fn eliminate_me() -> u32; + fn f1(x: u32) -> u32; + fn f2(x: u32) -> u32; + fn f3(x: u32) -> u32; + fn f4(x: u32) -> u32; + fn f5(x: u32) -> u32; +} diff --git a/tests/codegen/var-names.rs b/tests/codegen/var-names.rs index 4ea5b3b436d81..40720e197614e 100644 --- a/tests/codegen/var-names.rs +++ b/tests/codegen/var-names.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -C no-prepopulate-passes +//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/vec-as-ptr.rs b/tests/codegen/vec-as-ptr.rs index 17869c21c8321..5c997802640d2 100644 --- a/tests/codegen/vec-as-ptr.rs +++ b/tests/codegen/vec-as-ptr.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -Copt-level=3 -Zmerge-functions=disabled #![crate_type = "lib"] diff --git a/tests/codegen/vec-calloc.rs b/tests/codegen/vec-calloc.rs index f88ed7ae8a555..2e2769ce1301a 100644 --- a/tests/codegen/vec-calloc.rs +++ b/tests/codegen/vec-calloc.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled //@ only-x86_64 #![crate_type = "lib"] diff --git a/tests/codegen/vec-in-place.rs b/tests/codegen/vec-in-place.rs index e835a7ef69bd8..1f6836f6dfabb 100644 --- a/tests/codegen/vec-in-place.rs +++ b/tests/codegen/vec-in-place.rs @@ -1,5 +1,5 @@ //@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata) -//@ compile-flags: -O -Z merge-functions=disabled +//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled #![crate_type = "lib"] // Ensure that trivial casts of vec elements are O(1) diff --git a/tests/codegen/vec-iter-collect-len.rs b/tests/codegen/vec-iter-collect-len.rs index 8c5d2f6f9a74f..a88573522d4d8 100644 --- a/tests/codegen/vec-iter-collect-len.rs +++ b/tests/codegen/vec-iter-collect-len.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/vec-iter.rs b/tests/codegen/vec-iter.rs index 310680969c4fe..4ed00d2d34f0b 100644 --- a/tests/codegen/vec-iter.rs +++ b/tests/codegen/vec-iter.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #![feature(exact_size_is_empty)] diff --git a/tests/codegen/vec-len-invariant.rs b/tests/codegen/vec-len-invariant.rs index 780c86bab9569..033181c2bfb72 100644 --- a/tests/codegen/vec-len-invariant.rs +++ b/tests/codegen/vec-len-invariant.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ only-64bit // // This test confirms that we do not reload the length of a Vec after growing it in push. diff --git a/tests/codegen/vec-optimizes-away.rs b/tests/codegen/vec-optimizes-away.rs index 77a94b0b4294a..39d5c1614c82a 100644 --- a/tests/codegen/vec-optimizes-away.rs +++ b/tests/codegen/vec-optimizes-away.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] #[no_mangle] diff --git a/tests/codegen/vec-reserve-extend.rs b/tests/codegen/vec-reserve-extend.rs index 1f00f7d206339..4d3f23ccecfc8 100644 --- a/tests/codegen/vec-reserve-extend.rs +++ b/tests/codegen/vec-reserve-extend.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vec-shrink-panik.rs b/tests/codegen/vec-shrink-panik.rs index 873904c2569e4..23dd300d48cd6 100644 --- a/tests/codegen/vec-shrink-panik.rs +++ b/tests/codegen/vec-shrink-panik.rs @@ -1,6 +1,6 @@ // LLVM 17 realizes double panic is not possible and doesn't generate calls // to panic_cannot_unwind. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions (plain old debug assertions) //@ needs-unwind #![crate_type = "lib"] diff --git a/tests/codegen/vec-with-capacity.rs b/tests/codegen/vec-with-capacity.rs index e8c5bc88bd0db..777bbcc4fcb47 100644 --- a/tests/codegen/vec-with-capacity.rs +++ b/tests/codegen/vec-with-capacity.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions // (with debug assertions turned on, `assert_unchecked` generates a real assertion) diff --git a/tests/codegen/vec_pop_push_noop.rs b/tests/codegen/vec_pop_push_noop.rs index 4821e84088408..2635660596ab1 100644 --- a/tests/codegen/vec_pop_push_noop.rs +++ b/tests/codegen/vec_pop_push_noop.rs @@ -1,7 +1,7 @@ //@ revisions: llvm-pre-19 llvm-19 //@ [llvm-19] min-llvm-version: 19 //@ [llvm-pre-19] max-llvm-major-version: 18 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque-drain.rs b/tests/codegen/vecdeque-drain.rs index 8a34ba0674b1b..a5e5da6501332 100644 --- a/tests/codegen/vecdeque-drain.rs +++ b/tests/codegen/vecdeque-drain.rs @@ -1,6 +1,6 @@ // Check that draining at the front or back doesn't copy memory. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ needs-deterministic-layouts //@ ignore-std-debug-assertions (FIXME: checks for call detect scoped noalias metadata) diff --git a/tests/codegen/vecdeque-nonempty-get-no-panic.rs b/tests/codegen/vecdeque-nonempty-get-no-panic.rs index 3f802de9eeed7..1f886b096bbbf 100644 --- a/tests/codegen/vecdeque-nonempty-get-no-panic.rs +++ b/tests/codegen/vecdeque-nonempty-get-no-panic.rs @@ -1,6 +1,6 @@ // Guards against regression for optimization discussed in issue #80836 -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque_no_panic.rs b/tests/codegen/vecdeque_no_panic.rs index da948d12254cd..3166842afca0e 100644 --- a/tests/codegen/vecdeque_no_panic.rs +++ b/tests/codegen/vecdeque_no_panic.rs @@ -1,6 +1,6 @@ // This test checks that `VecDeque::front[_mut]()` and `VecDeque::back[_mut]()` can't panic. -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 //@ ignore-std-debug-assertions (plain old debug assertions) #![crate_type = "lib"] diff --git a/tests/codegen/vecdeque_pop_push.rs b/tests/codegen/vecdeque_pop_push.rs index 040d5a279dcab..5afa1b2248b0e 100644 --- a/tests/codegen/vecdeque_pop_push.rs +++ b/tests/codegen/vecdeque_pop_push.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/virtual-function-elimination-32bit.rs b/tests/codegen/virtual-function-elimination-32bit.rs index 76223be1f3dad..c9919cecccf9b 100644 --- a/tests/codegen/virtual-function-elimination-32bit.rs +++ b/tests/codegen/virtual-function-elimination-32bit.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0 +//@ compile-flags: -Zvirtual-function-elimination -Clto -Copt-level=3 -Csymbol-mangling-version=v0 //@ ignore-64bit // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] diff --git a/tests/codegen/virtual-function-elimination.rs b/tests/codegen/virtual-function-elimination.rs index 23d7657baa99b..d2d0c4b78abd1 100644 --- a/tests/codegen/virtual-function-elimination.rs +++ b/tests/codegen/virtual-function-elimination.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0 +//@ compile-flags: -Zvirtual-function-elimination -Clto -Copt-level=3 -Csymbol-mangling-version=v0 //@ ignore-32bit // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] diff --git a/tests/codegen/vtable-loads.rs b/tests/codegen/vtable-loads.rs index 1dd6ca51063b1..aa103ec6f7cb8 100644 --- a/tests/codegen/vtable-loads.rs +++ b/tests/codegen/vtable-loads.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/codegen/zip.rs b/tests/codegen/zip.rs index ea8caba61f396..38ecf7c15c675 100644 --- a/tests/codegen/zip.rs +++ b/tests/codegen/zip.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes -O +//@ compile-flags: -Cno-prepopulate-passes -Copt-level=3 #![crate_type = "lib"] diff --git a/tests/incremental/feature_gate.rs b/tests/incremental/feature_gate.rs index 54c2dbb352e14..332cf944b5d65 100644 --- a/tests/incremental/feature_gate.rs +++ b/tests/incremental/feature_gate.rs @@ -10,4 +10,4 @@ fn main() { } extern "unadjusted" fn foo() {} -//[cfail2]~^ ERROR: unadjusted ABI is an implementation detail and perma-unstable +//[cfail2]~^ ERROR: "unadjusted" ABI is an implementation detail and perma-unstable diff --git a/tests/ui/abi/removed-wasm-abi.rs b/tests/ui/abi/removed-wasm-abi.rs deleted file mode 100644 index a45e42bfe020e..0000000000000 --- a/tests/ui/abi/removed-wasm-abi.rs +++ /dev/null @@ -1,4 +0,0 @@ -extern "wasm" fn test() {} -//~^ ERROR invalid ABI: found `wasm` - -fn main() {} diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr index e80411fda344e..e1f433479857a 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr @@ -8,10 +8,9 @@ LL | extern "riscv-interrupt" fn isr() {} | help: did you mean: `"riscv-interrupt-m"` | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions - = note: please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively error[E0703]: invalid ABI: found `riscv-interrupt-u` - --> $DIR/riscv-discoverability-guidance.rs:23:8 + --> $DIR/riscv-discoverability-guidance.rs:22:8 | LL | extern "riscv-interrupt-u" fn isr_U() {} | ^^^^^^^^^^^^^^^^^^^ @@ -20,7 +19,6 @@ LL | extern "riscv-interrupt-u" fn isr_U() {} | help: did you mean: `"riscv-interrupt-m"` | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions - = note: user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314 error: aborting due to 2 previous errors diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr index e80411fda344e..e1f433479857a 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr @@ -8,10 +8,9 @@ LL | extern "riscv-interrupt" fn isr() {} | help: did you mean: `"riscv-interrupt-m"` | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions - = note: please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively error[E0703]: invalid ABI: found `riscv-interrupt-u` - --> $DIR/riscv-discoverability-guidance.rs:23:8 + --> $DIR/riscv-discoverability-guidance.rs:22:8 | LL | extern "riscv-interrupt-u" fn isr_U() {} | ^^^^^^^^^^^^^^^^^^^ @@ -20,7 +19,6 @@ LL | extern "riscv-interrupt-u" fn isr_U() {} | help: did you mean: `"riscv-interrupt-m"` | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions - = note: user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314 error: aborting due to 2 previous errors diff --git a/tests/ui/abi/riscv-discoverability-guidance.rs b/tests/ui/abi/riscv-discoverability-guidance.rs index 1b189d907baf6..dec5059b0a7f0 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.rs +++ b/tests/ui/abi/riscv-discoverability-guidance.rs @@ -18,10 +18,8 @@ extern "riscv-interrupt" fn isr() {} //~^ ERROR invalid ABI //~^^ NOTE invalid ABI //~^^^ NOTE invoke `rustc --print=calling-conventions` for a full list of supported calling conventions -//~^^^^ NOTE please use one of riscv-interrupt-m or riscv-interrupt-s extern "riscv-interrupt-u" fn isr_U() {} //~^ ERROR invalid ABI //~^^ NOTE invalid ABI //~^^^ NOTE invoke `rustc --print=calling-conventions` for a full list of supported calling conventions -//~^^^^ NOTE user-mode interrupt handlers have been removed from LLVM pending standardization diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr index 120d5cc5293b4..63260b5c78fdc 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr @@ -1,4 +1,4 @@ -error[E0658]: C-cmse-nonsecure-call ABI is experimental and subject to change +error[E0658]: the extern "C-cmse-nonsecure-call" ABI is experimental and subject to change --> $DIR/gate_test.rs:5:46 | LL | core::mem::transmute:: i32>( diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr index dabf16cab3098..0afbbe647af0c 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr @@ -1,4 +1,4 @@ -error[E0658]: C-cmse-nonsecure-entry ABI is experimental and subject to change +error[E0658]: the extern "C-cmse-nonsecure-entry" ABI is experimental and subject to change --> $DIR/gate_test.rs:4:12 | LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { diff --git a/tests/ui/extern/fictional-abi.rs b/tests/ui/extern/fictional-abi.rs new file mode 100644 index 0000000000000..60b24f8856efc --- /dev/null +++ b/tests/ui/extern/fictional-abi.rs @@ -0,0 +1,3 @@ +#![crate_type = "lib"] + +pub extern "fictional" fn lol() {} //~ ERROR: invalid ABI diff --git a/tests/ui/abi/removed-wasm-abi.stderr b/tests/ui/extern/fictional-abi.stderr similarity index 53% rename from tests/ui/abi/removed-wasm-abi.stderr rename to tests/ui/extern/fictional-abi.stderr index 6007c4e258014..9784a57776fc0 100644 --- a/tests/ui/abi/removed-wasm-abi.stderr +++ b/tests/ui/extern/fictional-abi.stderr @@ -1,11 +1,10 @@ -error[E0703]: invalid ABI: found `wasm` - --> $DIR/removed-wasm-abi.rs:1:8 +error[E0703]: invalid ABI: found `fictional` + --> $DIR/fictional-abi.rs:3:12 | -LL | extern "wasm" fn test() {} - | ^^^^^^ invalid ABI +LL | pub extern "fictional" fn lol() {} + | ^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions - = note: non-standard wasm ABI is no longer supported error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs index f37c5335deb04..5386628a8e069 100644 --- a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs @@ -9,43 +9,43 @@ trait Sized { } // feature gate is not used. extern "avr-non-blocking-interrupt" fn fu() {} -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental extern "avr-interrupt" fn f() {} -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-interrupt" ABI is experimental trait T { extern "avr-interrupt" fn m(); - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-interrupt" ABI is experimental extern "avr-non-blocking-interrupt" fn mu(); - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental extern "avr-interrupt" fn dm() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-interrupt" ABI is experimental extern "avr-non-blocking-interrupt" fn dmu() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental } struct S; impl T for S { extern "avr-interrupt" fn m() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-interrupt" ABI is experimental extern "avr-non-blocking-interrupt" fn mu() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental } impl S { extern "avr-interrupt" fn im() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-interrupt" ABI is experimental extern "avr-non-blocking-interrupt" fn imu() {} - //~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental + //~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental } type TA = extern "avr-interrupt" fn(); -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-interrupt" ABI is experimental type TAU = extern "avr-non-blocking-interrupt" fn(); -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental extern "avr-interrupt" {} -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-interrupt" ABI is experimental extern "avr-non-blocking-interrupt" {} -//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental +//~^ ERROR extern "avr-non-blocking-interrupt" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr index c6786699de1b8..d9f3c3adc7f04 100644 --- a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr @@ -1,4 +1,4 @@ -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:11:8 | LL | extern "avr-non-blocking-interrupt" fn fu() {} @@ -8,7 +8,7 @@ LL | extern "avr-non-blocking-interrupt" fn fu() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:13:8 | LL | extern "avr-interrupt" fn f() {} @@ -18,7 +18,7 @@ LL | extern "avr-interrupt" fn f() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:17:12 | LL | extern "avr-interrupt" fn m(); @@ -28,7 +28,7 @@ LL | extern "avr-interrupt" fn m(); = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:19:12 | LL | extern "avr-non-blocking-interrupt" fn mu(); @@ -38,7 +38,7 @@ LL | extern "avr-non-blocking-interrupt" fn mu(); = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:22:12 | LL | extern "avr-interrupt" fn dm() {} @@ -48,7 +48,7 @@ LL | extern "avr-interrupt" fn dm() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:24:12 | LL | extern "avr-non-blocking-interrupt" fn dmu() {} @@ -58,7 +58,7 @@ LL | extern "avr-non-blocking-interrupt" fn dmu() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:30:12 | LL | extern "avr-interrupt" fn m() {} @@ -68,7 +68,7 @@ LL | extern "avr-interrupt" fn m() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:32:12 | LL | extern "avr-non-blocking-interrupt" fn mu() {} @@ -78,7 +78,7 @@ LL | extern "avr-non-blocking-interrupt" fn mu() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:37:12 | LL | extern "avr-interrupt" fn im() {} @@ -88,7 +88,7 @@ LL | extern "avr-interrupt" fn im() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:39:12 | LL | extern "avr-non-blocking-interrupt" fn imu() {} @@ -98,7 +98,7 @@ LL | extern "avr-non-blocking-interrupt" fn imu() {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:43:18 | LL | type TA = extern "avr-interrupt" fn(); @@ -108,7 +108,7 @@ LL | type TA = extern "avr-interrupt" fn(); = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:45:19 | LL | type TAU = extern "avr-non-blocking-interrupt" fn(); @@ -118,7 +118,7 @@ LL | type TAU = extern "avr-non-blocking-interrupt" fn(); = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:48:8 | LL | extern "avr-interrupt" {} @@ -128,7 +128,7 @@ LL | extern "avr-interrupt" {} = help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-avr-interrupt.rs:50:8 | LL | extern "avr-non-blocking-interrupt" {} diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs index b0fb4c414d40f..bb69a638ceeab 100644 --- a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs @@ -6,29 +6,29 @@ trait Sized { } extern "msp430-interrupt" fn f() {} -//~^ ERROR msp430-interrupt ABI is experimental +//~^ ERROR "msp430-interrupt" ABI is experimental trait T { extern "msp430-interrupt" fn m(); - //~^ ERROR msp430-interrupt ABI is experimental + //~^ ERROR "msp430-interrupt" ABI is experimental extern "msp430-interrupt" fn dm() {} - //~^ ERROR msp430-interrupt ABI is experimental + //~^ ERROR "msp430-interrupt" ABI is experimental } struct S; impl T for S { extern "msp430-interrupt" fn m() {} - //~^ ERROR msp430-interrupt ABI is experimental + //~^ ERROR "msp430-interrupt" ABI is experimental } impl S { extern "msp430-interrupt" fn im() {} - //~^ ERROR msp430-interrupt ABI is experimental + //~^ ERROR "msp430-interrupt" ABI is experimental } type TA = extern "msp430-interrupt" fn(); -//~^ ERROR msp430-interrupt ABI is experimental +//~^ ERROR "msp430-interrupt" ABI is experimental extern "msp430-interrupt" {} -//~^ ERROR msp430-interrupt ABI is experimental +//~^ ERROR "msp430-interrupt" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr index 5dacc86dcc59c..21ddbf7a86df8 100644 --- a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr @@ -1,4 +1,4 @@ -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:8:8 | LL | extern "msp430-interrupt" fn f() {} @@ -8,7 +8,7 @@ LL | extern "msp430-interrupt" fn f() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:12:12 | LL | extern "msp430-interrupt" fn m(); @@ -18,7 +18,7 @@ LL | extern "msp430-interrupt" fn m(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:15:12 | LL | extern "msp430-interrupt" fn dm() {} @@ -28,7 +28,7 @@ LL | extern "msp430-interrupt" fn dm() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:21:12 | LL | extern "msp430-interrupt" fn m() {} @@ -38,7 +38,7 @@ LL | extern "msp430-interrupt" fn m() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:26:12 | LL | extern "msp430-interrupt" fn im() {} @@ -48,7 +48,7 @@ LL | extern "msp430-interrupt" fn im() {} = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:30:18 | LL | type TA = extern "msp430-interrupt" fn(); @@ -58,7 +58,7 @@ LL | type TA = extern "msp430-interrupt" fn(); = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: msp430-interrupt ABI is experimental and subject to change +error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-msp430-interrupt.rs:33:8 | LL | extern "msp430-interrupt" {} diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs index 29820f8877d33..6f4989fbd9fe9 100644 --- a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs @@ -9,25 +9,25 @@ trait Sized {} // feature gate is not used. extern "riscv-interrupt-m" fn f() {} -//~^ ERROR riscv-interrupt ABIs are experimental +//~^ ERROR "riscv-interrupt-m" ABI is experimental extern "riscv-interrupt-s" fn f_s() {} -//~^ ERROR riscv-interrupt ABIs are experimental +//~^ ERROR "riscv-interrupt-s" ABI is experimental trait T { extern "riscv-interrupt-m" fn m(); - //~^ ERROR riscv-interrupt ABIs are experimental + //~^ ERROR "riscv-interrupt-m" ABI is experimental } struct S; impl T for S { extern "riscv-interrupt-m" fn m() {} - //~^ ERROR riscv-interrupt ABIs are experimental + //~^ ERROR "riscv-interrupt-m" ABI is experimental } impl S { extern "riscv-interrupt-m" fn im() {} - //~^ ERROR riscv-interrupt ABIs are experimental + //~^ ERROR "riscv-interrupt-m" ABI is experimental } type TA = extern "riscv-interrupt-m" fn(); -//~^ ERROR riscv-interrupt ABIs are experimental +//~^ ERROR "riscv-interrupt-m" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr index 6b7853a320b0d..3c9e99aa1b9b3 100644 --- a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr @@ -1,4 +1,4 @@ -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:11:8 | LL | extern "riscv-interrupt-m" fn f() {} @@ -8,7 +8,7 @@ LL | extern "riscv-interrupt-m" fn f() {} = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-s" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:13:8 | LL | extern "riscv-interrupt-s" fn f_s() {} @@ -18,7 +18,7 @@ LL | extern "riscv-interrupt-s" fn f_s() {} = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:17:12 | LL | extern "riscv-interrupt-m" fn m(); @@ -28,7 +28,7 @@ LL | extern "riscv-interrupt-m" fn m(); = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:23:12 | LL | extern "riscv-interrupt-m" fn m() {} @@ -38,7 +38,7 @@ LL | extern "riscv-interrupt-m" fn m() {} = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:28:12 | LL | extern "riscv-interrupt-m" fn im() {} @@ -48,7 +48,7 @@ LL | extern "riscv-interrupt-m" fn im() {} = help: add `#![feature(abi_riscv_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: riscv-interrupt ABIs are experimental and subject to change +error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change --> $DIR/feature-gate-abi-riscv-interrupt.rs:32:18 | LL | type TA = extern "riscv-interrupt-m" fn(); diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs index 812ca12c7c37d..93c59364f10ba 100644 --- a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs @@ -5,24 +5,24 @@ #[lang="sized"] trait Sized { } -extern "x86-interrupt" fn f7() {} //~ ERROR x86-interrupt ABI is experimental +extern "x86-interrupt" fn f7() {} //~ ERROR "x86-interrupt" ABI is experimental trait Tr { - extern "x86-interrupt" fn m7(); //~ ERROR x86-interrupt ABI is experimental - extern "x86-interrupt" fn dm7() {} //~ ERROR x86-interrupt ABI is experimental + extern "x86-interrupt" fn m7(); //~ ERROR "x86-interrupt" ABI is experimental + extern "x86-interrupt" fn dm7() {} //~ ERROR "x86-interrupt" ABI is experimental } struct S; // Methods in trait impl impl Tr for S { - extern "x86-interrupt" fn m7() {} //~ ERROR x86-interrupt ABI is experimental + extern "x86-interrupt" fn m7() {} //~ ERROR "x86-interrupt" ABI is experimental } // Methods in inherent impl impl S { - extern "x86-interrupt" fn im7() {} //~ ERROR x86-interrupt ABI is experimental + extern "x86-interrupt" fn im7() {} //~ ERROR "x86-interrupt" ABI is experimental } -type A7 = extern "x86-interrupt" fn(); //~ ERROR x86-interrupt ABI is experimental +type A7 = extern "x86-interrupt" fn(); //~ ERROR "x86-interrupt" ABI is experimental -extern "x86-interrupt" {} //~ ERROR x86-interrupt ABI is experimental +extern "x86-interrupt" {} //~ ERROR "x86-interrupt" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr index 860005cac3416..231cf207c862d 100644 --- a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr @@ -1,4 +1,4 @@ -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:8:8 | LL | extern "x86-interrupt" fn f7() {} @@ -8,7 +8,7 @@ LL | extern "x86-interrupt" fn f7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:10:12 | LL | extern "x86-interrupt" fn m7(); @@ -18,7 +18,7 @@ LL | extern "x86-interrupt" fn m7(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:11:12 | LL | extern "x86-interrupt" fn dm7() {} @@ -28,7 +28,7 @@ LL | extern "x86-interrupt" fn dm7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:18:12 | LL | extern "x86-interrupt" fn m7() {} @@ -38,7 +38,7 @@ LL | extern "x86-interrupt" fn m7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:23:12 | LL | extern "x86-interrupt" fn im7() {} @@ -48,7 +48,7 @@ LL | extern "x86-interrupt" fn im7() {} = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:26:18 | LL | type A7 = extern "x86-interrupt" fn(); @@ -58,7 +58,7 @@ LL | type A7 = extern "x86-interrupt" fn(); = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: x86-interrupt ABI is experimental and subject to change +error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change --> $DIR/feature-gate-abi-x86-interrupt.rs:28:8 | LL | extern "x86-interrupt" {} diff --git a/tests/ui/feature-gates/feature-gate-abi.rs b/tests/ui/feature-gates/feature-gate-abi.rs index 3aa430e736f09..7ab05889c20a7 100644 --- a/tests/ui/feature-gates/feature-gate-abi.rs +++ b/tests/ui/feature-gates/feature-gate-abi.rs @@ -11,49 +11,49 @@ trait Sized { } trait Tuple { } // Functions -extern "rust-intrinsic" fn f1() {} //~ ERROR intrinsics are subject to change +extern "rust-intrinsic" fn f1() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in -extern "rust-intrinsic" fn f2() {} //~ ERROR intrinsics are subject to change +extern "rust-intrinsic" fn f2() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in -extern "rust-call" fn f4(_: ()) {} //~ ERROR rust-call ABI is subject to change +extern "rust-call" fn f4(_: ()) {} //~ ERROR extern "rust-call" ABI is experimental and subject to change // Methods in trait definition trait Tr { - extern "rust-intrinsic" fn m1(); //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn m1(); //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-intrinsic" fn m2(); //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn m2(); //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-call" fn m4(_: ()); //~ ERROR rust-call ABI is subject to change + extern "rust-call" fn m4(_: ()); //~ ERROR extern "rust-call" ABI is experimental and subject to change - extern "rust-call" fn dm4(_: ()) {} //~ ERROR rust-call ABI is subject to change + extern "rust-call" fn dm4(_: ()) {} //~ ERROR extern "rust-call" ABI is experimental and subject to change } struct S; // Methods in trait impl impl Tr for S { - extern "rust-intrinsic" fn m1() {} //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn m1() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-intrinsic" fn m2() {} //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn m2() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-call" fn m4(_: ()) {} //~ ERROR rust-call ABI is subject to change + extern "rust-call" fn m4(_: ()) {} //~ ERROR extern "rust-call" ABI is experimental and subject to change } // Methods in inherent impl impl S { - extern "rust-intrinsic" fn im1() {} //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn im1() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-intrinsic" fn im2() {} //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" fn im2() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in - extern "rust-call" fn im4(_: ()) {} //~ ERROR rust-call ABI is subject to change + extern "rust-call" fn im4(_: ()) {} //~ ERROR extern "rust-call" ABI is experimental and subject to change } // Function pointer types -type A1 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change -type A2 = extern "rust-intrinsic" fn(); //~ ERROR intrinsics are subject to change -type A4 = extern "rust-call" fn(_: ()); //~ ERROR rust-call ABI is subject to change +type A1 = extern "rust-intrinsic" fn(); //~ ERROR extern "rust-intrinsic" ABI is an implementation detail +type A2 = extern "rust-intrinsic" fn(); //~ ERROR extern "rust-intrinsic" ABI is an implementation detail +type A4 = extern "rust-call" fn(_: ()); //~ ERROR extern "rust-call" ABI is experimental and subject to change // Foreign modules -extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change -extern "rust-intrinsic" {} //~ ERROR intrinsics are subject to change -extern "rust-call" {} //~ ERROR rust-call ABI is subject to change +extern "rust-intrinsic" {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail +extern "rust-intrinsic" {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail +extern "rust-call" {} //~ ERROR extern "rust-call" ABI is experimental and subject to change diff --git a/tests/ui/feature-gates/feature-gate-abi.stderr b/tests/ui/feature-gates/feature-gate-abi.stderr index dbdfa7b275d49..70ec64e5135e5 100644 --- a/tests/ui/feature-gates/feature-gate-abi.stderr +++ b/tests/ui/feature-gates/feature-gate-abi.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:14:8 | LL | extern "rust-intrinsic" fn f1() {} @@ -7,7 +7,7 @@ LL | extern "rust-intrinsic" fn f1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:16:8 | LL | extern "rust-intrinsic" fn f2() {} @@ -16,7 +16,7 @@ LL | extern "rust-intrinsic" fn f2() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:18:8 | LL | extern "rust-call" fn f4(_: ()) {} @@ -26,7 +26,7 @@ LL | extern "rust-call" fn f4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:22:12 | LL | extern "rust-intrinsic" fn m1(); @@ -35,7 +35,7 @@ LL | extern "rust-intrinsic" fn m1(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:24:12 | LL | extern "rust-intrinsic" fn m2(); @@ -44,7 +44,7 @@ LL | extern "rust-intrinsic" fn m2(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:26:12 | LL | extern "rust-call" fn m4(_: ()); @@ -54,7 +54,7 @@ LL | extern "rust-call" fn m4(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:28:12 | LL | extern "rust-call" fn dm4(_: ()) {} @@ -64,7 +64,7 @@ LL | extern "rust-call" fn dm4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:35:12 | LL | extern "rust-intrinsic" fn m1() {} @@ -73,7 +73,7 @@ LL | extern "rust-intrinsic" fn m1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:37:12 | LL | extern "rust-intrinsic" fn m2() {} @@ -82,7 +82,7 @@ LL | extern "rust-intrinsic" fn m2() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:39:12 | LL | extern "rust-call" fn m4(_: ()) {} @@ -92,7 +92,7 @@ LL | extern "rust-call" fn m4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:44:12 | LL | extern "rust-intrinsic" fn im1() {} @@ -101,7 +101,7 @@ LL | extern "rust-intrinsic" fn im1() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:46:12 | LL | extern "rust-intrinsic" fn im2() {} @@ -110,7 +110,7 @@ LL | extern "rust-intrinsic" fn im2() {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:48:12 | LL | extern "rust-call" fn im4(_: ()) {} @@ -120,7 +120,7 @@ LL | extern "rust-call" fn im4(_: ()) {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:52:18 | LL | type A1 = extern "rust-intrinsic" fn(); @@ -129,7 +129,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:53:18 | LL | type A2 = extern "rust-intrinsic" fn(); @@ -138,7 +138,7 @@ LL | type A2 = extern "rust-intrinsic" fn(); = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:54:18 | LL | type A4 = extern "rust-call" fn(_: ()); @@ -148,7 +148,7 @@ LL | type A4 = extern "rust-call" fn(_: ()); = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:57:8 | LL | extern "rust-intrinsic" {} @@ -157,7 +157,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi.rs:58:8 | LL | extern "rust-intrinsic" {} @@ -166,7 +166,7 @@ LL | extern "rust-intrinsic" {} = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-abi.rs:59:8 | LL | extern "rust-call" {} diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs index 7d39820f086e9..fb04906dafe96 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs @@ -10,14 +10,14 @@ trait Sized { } trait Tuple { } // Functions -extern "gpu-kernel" fn f1(_: ()) {} //~ ERROR gpu-kernel ABI is experimental and subject to change +extern "gpu-kernel" fn f1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ ERROR is not a supported ABI // Methods in trait definition trait Tr { - extern "gpu-kernel" fn m1(_: ()); //~ ERROR gpu-kernel ABI is experimental and subject to change + extern "gpu-kernel" fn m1(_: ()); //~ ERROR "gpu-kernel" ABI is experimental and subject to change - extern "gpu-kernel" fn dm1(_: ()) {} //~ ERROR gpu-kernel ABI is experimental and subject to change + extern "gpu-kernel" fn dm1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ ERROR is not a supported ABI } @@ -25,21 +25,21 @@ struct S; // Methods in trait impl impl Tr for S { - extern "gpu-kernel" fn m1(_: ()) {} //~ ERROR gpu-kernel ABI is experimental and subject to change + extern "gpu-kernel" fn m1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ ERROR is not a supported ABI } // Methods in inherent impl impl S { - extern "gpu-kernel" fn im1(_: ()) {} //~ ERROR gpu-kernel ABI is experimental and subject to change + extern "gpu-kernel" fn im1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ ERROR is not a supported ABI } // Function pointer types -type A1 = extern "gpu-kernel" fn(_: ()); //~ ERROR gpu-kernel ABI is experimental and subject to change +type A1 = extern "gpu-kernel" fn(_: ()); //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ WARN the calling convention "gpu-kernel" is not supported on this target //~^^ WARN this was previously accepted by the compiler but is being phased out // Foreign modules -extern "gpu-kernel" {} //~ ERROR gpu-kernel ABI is experimental and subject to change +extern "gpu-kernel" {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //~^ ERROR is not a supported ABI diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr index 771c49acb97a5..b05c16e3d9ee2 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr @@ -1,4 +1,4 @@ -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:13:8 | LL | extern "gpu-kernel" fn f1(_: ()) {} @@ -8,7 +8,7 @@ LL | extern "gpu-kernel" fn f1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:18:12 | LL | extern "gpu-kernel" fn m1(_: ()); @@ -18,7 +18,7 @@ LL | extern "gpu-kernel" fn m1(_: ()); = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:20:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} @@ -28,7 +28,7 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:28:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} @@ -38,7 +38,7 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:34:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} @@ -48,7 +48,7 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:39:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); @@ -58,7 +58,7 @@ LL | type A1 = extern "gpu-kernel" fn(_: ()); = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: gpu-kernel ABI is experimental and subject to change +error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:44:8 | LL | extern "gpu-kernel" {} diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.rs b/tests/ui/feature-gates/feature-gate-abi_ptx.rs index 83f48430281a3..e742492303ade 100644 --- a/tests/ui/feature-gates/feature-gate-abi_ptx.rs +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.rs @@ -5,22 +5,22 @@ #[lang="sized"] trait Sized { } -extern "ptx-kernel" fn fu() {} //~ ERROR PTX ABIs are experimental +extern "ptx-kernel" fn fu() {} //~ ERROR extern "ptx-kernel" ABI is experimental trait T { - extern "ptx-kernel" fn mu(); //~ ERROR PTX ABIs are experimental - extern "ptx-kernel" fn dmu() {} //~ ERROR PTX ABIs are experimental + extern "ptx-kernel" fn mu(); //~ ERROR extern "ptx-kernel" ABI is experimental + extern "ptx-kernel" fn dmu() {} //~ ERROR extern "ptx-kernel" ABI is experimental } struct S; impl T for S { - extern "ptx-kernel" fn mu() {} //~ ERROR PTX ABIs are experimental + extern "ptx-kernel" fn mu() {} //~ ERROR extern "ptx-kernel" ABI is experimental } impl S { - extern "ptx-kernel" fn imu() {} //~ ERROR PTX ABIs are experimental + extern "ptx-kernel" fn imu() {} //~ ERROR extern "ptx-kernel" ABI is experimental } -type TAU = extern "ptx-kernel" fn(); //~ ERROR PTX ABIs are experimental +type TAU = extern "ptx-kernel" fn(); //~ ERROR extern "ptx-kernel" ABI is experimental -extern "ptx-kernel" {} //~ ERROR PTX ABIs are experimental +extern "ptx-kernel" {} //~ ERROR extern "ptx-kernel" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.stderr b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr index 22b493e577dd5..d128075919b09 100644 --- a/tests/ui/feature-gates/feature-gate-abi_ptx.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr @@ -1,4 +1,4 @@ -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:8:8 | LL | extern "ptx-kernel" fn fu() {} @@ -8,7 +8,7 @@ LL | extern "ptx-kernel" fn fu() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:11:12 | LL | extern "ptx-kernel" fn mu(); @@ -18,7 +18,7 @@ LL | extern "ptx-kernel" fn mu(); = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:12:12 | LL | extern "ptx-kernel" fn dmu() {} @@ -28,7 +28,7 @@ LL | extern "ptx-kernel" fn dmu() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:17:12 | LL | extern "ptx-kernel" fn mu() {} @@ -38,7 +38,7 @@ LL | extern "ptx-kernel" fn mu() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:21:12 | LL | extern "ptx-kernel" fn imu() {} @@ -48,7 +48,7 @@ LL | extern "ptx-kernel" fn imu() {} = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:24:19 | LL | type TAU = extern "ptx-kernel" fn(); @@ -58,7 +58,7 @@ LL | type TAU = extern "ptx-kernel" fn(); = help: add `#![feature(abi_ptx)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: PTX ABIs are experimental and subject to change +error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_ptx.rs:26:8 | LL | extern "ptx-kernel" {} diff --git a/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs b/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs index 35a7d73288b5d..1dc6adc0e1495 100644 --- a/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs +++ b/tests/ui/feature-gates/feature-gate-abi_unadjusted.rs @@ -1,5 +1,5 @@ extern "unadjusted" fn foo() { -//~^ ERROR: unadjusted ABI is an implementation detail and perma-unstable +//~^ ERROR: "unadjusted" ABI is an implementation detail and perma-unstable } fn main() { diff --git a/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr b/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr index 1d5fb11cd3d2b..462fb79d55703 100644 --- a/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_unadjusted.stderr @@ -1,4 +1,4 @@ -error[E0658]: unadjusted ABI is an implementation detail and perma-unstable +error[E0658]: the extern "unadjusted" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi_unadjusted.rs:1:8 | LL | extern "unadjusted" fn foo() { diff --git a/tests/ui/feature-gates/feature-gate-intrinsics.rs b/tests/ui/feature-gates/feature-gate-intrinsics.rs index e0dc3cc579d79..65806a0223e74 100644 --- a/tests/ui/feature-gates/feature-gate-intrinsics.rs +++ b/tests/ui/feature-gates/feature-gate-intrinsics.rs @@ -1,8 +1,8 @@ -extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change +extern "rust-intrinsic" { //~ ERROR "rust-intrinsic" ABI is an implementation detail fn bar(); //~ ERROR unrecognized intrinsic function: `bar` } -extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change +extern "rust-intrinsic" fn baz() {} //~ ERROR "rust-intrinsic" ABI is an implementation detail //~^ ERROR intrinsic must be in fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-intrinsics.stderr b/tests/ui/feature-gates/feature-gate-intrinsics.stderr index 577a620e2d2c5..97246f05258f0 100644 --- a/tests/ui/feature-gates/feature-gate-intrinsics.stderr +++ b/tests/ui/feature-gates/feature-gate-intrinsics.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-intrinsics.rs:1:8 | LL | extern "rust-intrinsic" { @@ -7,7 +7,7 @@ LL | extern "rust-intrinsic" { = help: add `#![feature(intrinsics)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-intrinsics.rs:5:8 | LL | extern "rust-intrinsic" fn baz() {} diff --git a/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs b/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs index 9ba8e32ac07a3..4f47eb55b395f 100644 --- a/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs +++ b/tests/ui/feature-gates/feature-gate-rust_cold_cc.rs @@ -1,21 +1,21 @@ #![crate_type = "lib"] -extern "rust-cold" fn fu() {} //~ ERROR rust-cold is experimental +extern "rust-cold" fn fu() {} //~ ERROR "rust-cold" ABI is experimental trait T { - extern "rust-cold" fn mu(); //~ ERROR rust-cold is experimental - extern "rust-cold" fn dmu() {} //~ ERROR rust-cold is experimental + extern "rust-cold" fn mu(); //~ ERROR "rust-cold" ABI is experimental + extern "rust-cold" fn dmu() {} //~ ERROR "rust-cold" ABI is experimental } struct S; impl T for S { - extern "rust-cold" fn mu() {} //~ ERROR rust-cold is experimental + extern "rust-cold" fn mu() {} //~ ERROR "rust-cold" ABI is experimental } impl S { - extern "rust-cold" fn imu() {} //~ ERROR rust-cold is experimental + extern "rust-cold" fn imu() {} //~ ERROR "rust-cold" ABI is experimental } -type TAU = extern "rust-cold" fn(); //~ ERROR rust-cold is experimental +type TAU = extern "rust-cold" fn(); //~ ERROR "rust-cold" ABI is experimental -extern "rust-cold" {} //~ ERROR rust-cold is experimental +extern "rust-cold" {} //~ ERROR "rust-cold" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr b/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr index eeff9534d528f..9547c64f2b2ec 100644 --- a/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr +++ b/tests/ui/feature-gates/feature-gate-rust_cold_cc.stderr @@ -1,4 +1,4 @@ -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:3:8 | LL | extern "rust-cold" fn fu() {} @@ -8,7 +8,7 @@ LL | extern "rust-cold" fn fu() {} = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:6:12 | LL | extern "rust-cold" fn mu(); @@ -18,7 +18,7 @@ LL | extern "rust-cold" fn mu(); = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:7:12 | LL | extern "rust-cold" fn dmu() {} @@ -28,7 +28,7 @@ LL | extern "rust-cold" fn dmu() {} = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:12:12 | LL | extern "rust-cold" fn mu() {} @@ -38,7 +38,7 @@ LL | extern "rust-cold" fn mu() {} = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:16:12 | LL | extern "rust-cold" fn imu() {} @@ -48,7 +48,7 @@ LL | extern "rust-cold" fn imu() {} = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:19:19 | LL | type TAU = extern "rust-cold" fn(); @@ -58,7 +58,7 @@ LL | type TAU = extern "rust-cold" fn(); = help: add `#![feature(rust_cold_cc)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-cold is experimental and subject to change +error[E0658]: the extern "rust-cold" ABI is experimental and subject to change --> $DIR/feature-gate-rust_cold_cc.rs:21:8 | LL | extern "rust-cold" {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs index ff528274c59be..7b40c8760e368 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs @@ -11,7 +11,7 @@ impl Fn<()> for Foo { //~| ERROR manual implementations of `Fn` are experimental //~| ERROR expected a `FnMut()` closure, found `Foo` extern "rust-call" fn call(self, args: ()) -> () {} - //~^ ERROR rust-call ABI is subject to change + //~^ ERROR "rust-call" ABI is experimental and subject to change //~| ERROR `call` has an incompatible type for trait } struct Foo1; @@ -20,7 +20,7 @@ impl FnOnce() for Foo1 { //~| ERROR manual implementations of `FnOnce` are experimental //~| ERROR not all trait items implemented extern "rust-call" fn call_once(self, args: ()) -> () {} - //~^ ERROR rust-call ABI is subject to change + //~^ ERROR "rust-call" ABI is experimental and subject to change } struct Bar; impl FnMut<()> for Bar { @@ -28,7 +28,7 @@ impl FnMut<()> for Bar { //~| ERROR manual implementations of `FnMut` are experimental //~| ERROR expected a `FnOnce()` closure, found `Bar` extern "rust-call" fn call_mut(&self, args: ()) -> () {} - //~^ ERROR rust-call ABI is subject to change + //~^ ERROR "rust-call" ABI is experimental and subject to change //~| ERROR incompatible type for trait } struct Baz; @@ -37,7 +37,7 @@ impl FnOnce<()> for Baz { //~| ERROR manual implementations of `FnOnce` are experimental //~| ERROR not all trait items implemented extern "rust-call" fn call_once(&self, args: ()) -> () {} - //~^ ERROR rust-call ABI is subject to change + //~^ ERROR "rust-call" ABI is experimental and subject to change } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 584724dfe59cc..f9d231dc78f7c 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -1,4 +1,4 @@ -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:12 | LL | extern "rust-call" fn call(self, args: ()) -> () {} @@ -8,7 +8,7 @@ LL | extern "rust-call" fn call(self, args: ()) -> () {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:22:12 | LL | extern "rust-call" fn call_once(self, args: ()) -> () {} @@ -18,7 +18,7 @@ LL | extern "rust-call" fn call_once(self, args: ()) -> () {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:12 | LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} @@ -28,7 +28,7 @@ LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:39:12 | LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures.rs b/tests/ui/feature-gates/feature-gate-unboxed-closures.rs index ebc5a2536f672..74cc20c581cb9 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures.rs +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures.rs @@ -10,7 +10,7 @@ impl FnOnce<(u32, u32)> for Test { extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { a + b } - //~^^^ ERROR rust-call ABI is subject to change + //~^^^ ERROR "rust-call" ABI is experimental and subject to change } fn main() { diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr index 52c18ec34c564..36932c1f86f9f 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -1,4 +1,4 @@ -error[E0658]: rust-call ABI is subject to change +error[E0658]: the extern "rust-call" ABI is experimental and subject to change --> $DIR/feature-gate-unboxed-closures.rs:10:12 | LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.rs b/tests/ui/feature-gates/feature-gate-vectorcall.rs index 73a11a842f377..aafa6a2ed629b 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.rs +++ b/tests/ui/feature-gates/feature-gate-vectorcall.rs @@ -9,23 +9,23 @@ trait Sized { } // Test that the "vectorcall" ABI is feature-gated, and cannot be used when // the `vectorcall` feature gate is not used. -extern "vectorcall" fn f() {} //~ ERROR vectorcall is experimental +extern "vectorcall" fn f() {} //~ ERROR "vectorcall" ABI is experimental trait T { - extern "vectorcall" fn m(); //~ ERROR vectorcall is experimental + extern "vectorcall" fn m(); //~ ERROR "vectorcall" ABI is experimental - extern "vectorcall" fn dm() {} //~ ERROR vectorcall is experimental + extern "vectorcall" fn dm() {} //~ ERROR "vectorcall" ABI is experimental } struct S; impl T for S { - extern "vectorcall" fn m() {} //~ ERROR vectorcall is experimental + extern "vectorcall" fn m() {} //~ ERROR "vectorcall" ABI is experimental } impl S { - extern "vectorcall" fn im() {} //~ ERROR vectorcall is experimental + extern "vectorcall" fn im() {} //~ ERROR "vectorcall" ABI is experimental } -type TA = extern "vectorcall" fn(); //~ ERROR vectorcall is experimental +type TA = extern "vectorcall" fn(); //~ ERROR "vectorcall" ABI is experimental -extern "vectorcall" {} //~ ERROR vectorcall is experimental +extern "vectorcall" {} //~ ERROR "vectorcall" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.stderr b/tests/ui/feature-gates/feature-gate-vectorcall.stderr index b20e41887b9bf..8f3f47a3d4888 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.stderr +++ b/tests/ui/feature-gates/feature-gate-vectorcall.stderr @@ -1,4 +1,4 @@ -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:12:8 | LL | extern "vectorcall" fn f() {} @@ -8,7 +8,7 @@ LL | extern "vectorcall" fn f() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:15:12 | LL | extern "vectorcall" fn m(); @@ -18,7 +18,7 @@ LL | extern "vectorcall" fn m(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:17:12 | LL | extern "vectorcall" fn dm() {} @@ -28,7 +28,7 @@ LL | extern "vectorcall" fn dm() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:22:12 | LL | extern "vectorcall" fn m() {} @@ -38,7 +38,7 @@ LL | extern "vectorcall" fn m() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:26:12 | LL | extern "vectorcall" fn im() {} @@ -48,7 +48,7 @@ LL | extern "vectorcall" fn im() {} = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:29:18 | LL | type TA = extern "vectorcall" fn(); @@ -58,7 +58,7 @@ LL | type TA = extern "vectorcall" fn(); = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: vectorcall is experimental and subject to change +error[E0658]: the extern "vectorcall" ABI is experimental and subject to change --> $DIR/feature-gate-vectorcall.rs:31:8 | LL | extern "vectorcall" {} diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs index 37b7d52fafcae..2328798d74c32 100644 --- a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs +++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.rs @@ -5,7 +5,7 @@ fn main() { let a = &[1, 2, 3]; println!("{}", { - extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change + extern "rust-intrinsic" { //~ ERROR "rust-intrinsic" ABI is an implementation detail fn atomic_fence(); } atomic_fence(); //~ ERROR: is unsafe diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr index 3dc11b5612ca9..86f88fdff5fc8 100644 --- a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr +++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/feature-gated-feature-in-macro-arg.rs:8:16 | LL | extern "rust-intrinsic" { diff --git a/tests/ui/intrinsics/incorrect-read_via_copy-defn.rs b/tests/ui/intrinsics/incorrect-read_via_copy-defn.rs index 66de1f60ed9bc..5520430e140b3 100644 --- a/tests/ui/intrinsics/incorrect-read_via_copy-defn.rs +++ b/tests/ui/intrinsics/incorrect-read_via_copy-defn.rs @@ -3,5 +3,5 @@ fn main() { } extern "rust-intrinsic" fn read_via_copy() {} -//~^ ERROR intrinsics are subject to change +//~^ ERROR "rust-intrinsic" ABI is an implementation detail //~| ERROR intrinsic must be in `extern "rust-intrinsic" { ... }` block diff --git a/tests/ui/intrinsics/incorrect-read_via_copy-defn.stderr b/tests/ui/intrinsics/incorrect-read_via_copy-defn.stderr index 362ee185b7b17..c6682693f7409 100644 --- a/tests/ui/intrinsics/incorrect-read_via_copy-defn.stderr +++ b/tests/ui/intrinsics/incorrect-read_via_copy-defn.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/incorrect-read_via_copy-defn.rs:5:8 | LL | extern "rust-intrinsic" fn read_via_copy() {} diff --git a/tests/ui/intrinsics/incorrect-transmute.rs b/tests/ui/intrinsics/incorrect-transmute.rs index eed524ae8a8a2..15d1ab939ed0b 100644 --- a/tests/ui/intrinsics/incorrect-transmute.rs +++ b/tests/ui/intrinsics/incorrect-transmute.rs @@ -3,5 +3,5 @@ fn main() { } extern "rust-intrinsic" fn transmute() {} -//~^ ERROR intrinsics are subject to change +//~^ ERROR "rust-intrinsic" ABI is an implementation detail //~| ERROR intrinsic must be in `extern "rust-intrinsic" { ... }` block diff --git a/tests/ui/intrinsics/incorrect-transmute.stderr b/tests/ui/intrinsics/incorrect-transmute.stderr index 8123f3d71a295..99dfb9847ff2e 100644 --- a/tests/ui/intrinsics/incorrect-transmute.stderr +++ b/tests/ui/intrinsics/incorrect-transmute.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable --> $DIR/incorrect-transmute.rs:5:8 | LL | extern "rust-intrinsic" fn transmute() {} diff --git a/tests/ui/sse-abi-checks.rs b/tests/ui/sse-simd-abi-checks.rs similarity index 75% rename from tests/ui/sse-abi-checks.rs rename to tests/ui/sse-simd-abi-checks.rs index c453e91d11b2a..6b4e4afee348a 100644 --- a/tests/ui/sse-abi-checks.rs +++ b/tests/ui/sse-simd-abi-checks.rs @@ -1,6 +1,7 @@ //! Ensure we trigger abi_unsupported_vector_types for target features that are usually enabled -//! on a target, but disabled in this file via a `-C` flag. -//@ compile-flags: --crate-type=rlib --target=i686-unknown-linux-gnu -C target-feature=-sse,-sse2 +//! on a target via the base CPU, but disabled in this file via a `-C` flag. +//@ compile-flags: --crate-type=rlib --target=i586-unknown-linux-gnu +//@ compile-flags: -Ctarget-cpu=pentium4 -C target-feature=-sse,-sse2 //@ build-pass //@ ignore-pass (test emits codegen-time warnings) //@ needs-llvm-components: x86 diff --git a/tests/ui/sse-abi-checks.stderr b/tests/ui/sse-simd-abi-checks.stderr similarity index 94% rename from tests/ui/sse-abi-checks.stderr rename to tests/ui/sse-simd-abi-checks.stderr index e08b2d4e19179..f777d341b5343 100644 --- a/tests/ui/sse-abi-checks.stderr +++ b/tests/ui/sse-simd-abi-checks.stderr @@ -1,5 +1,5 @@ warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-abi-checks.rs:21:1 + --> $DIR/sse-simd-abi-checks.rs:22:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -13,7 +13,7 @@ warning: 1 warning emitted Future incompatibility report: Future breakage diagnostic: warning: this function definition uses a SIMD vector type that (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-abi-checks.rs:21:1 + --> $DIR/sse-simd-abi-checks.rs:22:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here diff --git a/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs new file mode 100644 index 0000000000000..28d026c1a9a2d --- /dev/null +++ b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.rs @@ -0,0 +1,12 @@ +//@ compile-flags: --target=i686-unknown-linux-gnu --crate-type=lib +//@ needs-llvm-components: x86 +//@ compile-flags: -Ctarget-cpu=pentium +// For now this is just a warning. +//@ build-pass +//@error-pattern: must be enabled + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} diff --git a/tests/ui/target-feature/target-cpu-lacks-required-target-feature.stderr b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.stderr new file mode 100644 index 0000000000000..7ec8b04cfce01 --- /dev/null +++ b/tests/ui/target-feature/target-cpu-lacks-required-target-feature.stderr @@ -0,0 +1,7 @@ +warning: target feature `sse2` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: 1 warning emitted +