From 79b2360d985d325741e066e7b6070ed465b785df Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 18 Feb 2025 16:51:47 +0100 Subject: [PATCH 1/2] mono-time abi_check: unify error paths for call and definition sites also move the existing tests to a more sensible location --- compiler/rustc_monomorphize/messages.ftl | 34 ++++--- compiler/rustc_monomorphize/src/errors.rs | 30 ++---- .../src/mono_checks/abi_check.rs | 94 +++++++++---------- .../{ => abi}/simd-abi-checks-empty-list.rs | 0 .../simd-abi-checks-empty-list.stderr | 0 tests/ui/{ => abi}/simd-abi-checks-s390x.rs | 0 .../simd-abi-checks-s390x.z10.stderr | 0 ...simd-abi-checks-s390x.z13_no_vector.stderr | 0 ...imd-abi-checks-s390x.z13_soft_float.stderr | 0 tests/ui/{ => abi}/simd-abi-checks.rs | 0 tests/ui/{ => abi}/simd-abi-checks.stderr | 0 tests/ui/abi/sse-abi-checks.rs | 23 +++++ tests/ui/abi/sse-abi-checks.stderr | 25 +++++ tests/ui/sse-simd-abi-checks.rs | 2 +- 14 files changed, 122 insertions(+), 86 deletions(-) rename tests/ui/{ => abi}/simd-abi-checks-empty-list.rs (100%) rename tests/ui/{ => abi}/simd-abi-checks-empty-list.stderr (100%) rename tests/ui/{ => abi}/simd-abi-checks-s390x.rs (100%) rename tests/ui/{ => abi}/simd-abi-checks-s390x.z10.stderr (100%) rename tests/ui/{ => abi}/simd-abi-checks-s390x.z13_no_vector.stderr (100%) rename tests/ui/{ => abi}/simd-abi-checks-s390x.z13_soft_float.stderr (100%) rename tests/ui/{ => abi}/simd-abi-checks.rs (100%) rename tests/ui/{ => abi}/simd-abi-checks.stderr (100%) create mode 100644 tests/ui/abi/sse-abi-checks.rs create mode 100644 tests/ui/abi/sse-abi-checks.stderr diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index 463c42b69b1af..a83c18cda0e2b 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -1,18 +1,26 @@ -monomorphize_abi_error_disabled_vector_type_call = - this function call uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled in the caller - .label = function called here - .help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`) -monomorphize_abi_error_disabled_vector_type_def = - this function definition uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled - .label = function defined here +monomorphize_abi_error_disabled_vector_type = + this function {$is_call -> + [true] call + *[false] definition + } uses SIMD vector type `{$ty}` which (with the chosen ABI) requires the `{$required_feature}` target feature, which is not enabled{$is_call -> + [true] {" "}in the caller + *[false] {""} + } + .label = function {$is_call -> + [true] called + *[false] defined + } here .help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`) -monomorphize_abi_error_unsupported_vector_type_call = - this function call uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI - .label = function called here -monomorphize_abi_error_unsupported_vector_type_def = - this function definition uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI - .label = function defined here +monomorphize_abi_error_unsupported_vector_type = + this function {$is_call -> + [true] call + *[false] definition + } uses SIMD vector type `{$ty}` which is not currently supported with the chosen ABI + .label = function {$is_call -> + [true] called + *[false] defined + } here monomorphize_couldnt_dump_mono_stats = unexpected error occurred while dumping monomorphization stats: {$error} diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index 75687a80b82ae..1cfcd52b66625 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -70,37 +70,23 @@ pub(crate) struct UnknownCguCollectionMode<'a> { } #[derive(LintDiagnostic)] -#[diag(monomorphize_abi_error_disabled_vector_type_def)] +#[diag(monomorphize_abi_error_disabled_vector_type)] #[help] -pub(crate) struct AbiErrorDisabledVectorTypeDef<'a> { +pub(crate) struct AbiErrorDisabledVectorType<'a> { #[label] pub span: Span, pub required_feature: &'a str, pub ty: Ty<'a>, + /// Whether this is a problem at a call site or at a declaration. + pub is_call: bool, } #[derive(LintDiagnostic)] -#[diag(monomorphize_abi_error_disabled_vector_type_call)] -#[help] -pub(crate) struct AbiErrorDisabledVectorTypeCall<'a> { - #[label] - pub span: Span, - pub required_feature: &'a str, - pub ty: Ty<'a>, -} - -#[derive(LintDiagnostic)] -#[diag(monomorphize_abi_error_unsupported_vector_type_def)] -pub(crate) struct AbiErrorUnsupportedVectorTypeDef<'a> { - #[label] - pub span: Span, - pub ty: Ty<'a>, -} - -#[derive(LintDiagnostic)] -#[diag(monomorphize_abi_error_unsupported_vector_type_call)] -pub(crate) struct AbiErrorUnsupportedVectorTypeCall<'a> { +#[diag(monomorphize_abi_error_unsupported_vector_type)] +pub(crate) struct AbiErrorUnsupportedVectorType<'a> { #[label] pub span: Span, pub ty: Ty<'a>, + /// Whether this is a problem at a call site or at a declaration. + pub is_call: bool, } diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index 8e93bdc61d04a..b5a7a81037950 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -6,13 +6,10 @@ use rustc_middle::mir::{self, traversal}; use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt}; use rustc_session::lint::builtin::ABI_UNSUPPORTED_VECTOR_TYPES; use rustc_span::def_id::DefId; -use rustc_span::{DUMMY_SP, Span, Symbol}; -use rustc_target::callconv::{FnAbi, PassMode}; +use rustc_span::{DUMMY_SP, Span, Symbol, sym}; +use rustc_target::callconv::{Conv, FnAbi, PassMode}; -use crate::errors::{ - AbiErrorDisabledVectorTypeCall, AbiErrorDisabledVectorTypeDef, - AbiErrorUnsupportedVectorTypeCall, AbiErrorUnsupportedVectorTypeDef, -}; +use crate::errors; fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool { match mode { @@ -27,16 +24,21 @@ fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool { /// Checks whether a certain function ABI is compatible with the target features currently enabled /// for a certain function. -/// If not, `emit_err` is called, with `Some(feature)` if a certain feature should be enabled and -/// with `None` if no feature is known that would make the ABI compatible. +/// `is_call` indicates whether this is a call-site check or a definition-site check; +/// this is only relevant for the wording in the emitted error. fn do_check_abi<'tcx>( tcx: TyCtxt<'tcx>, abi: &FnAbi<'tcx, Ty<'tcx>>, target_feature_def: DefId, - mut emit_err: impl FnMut(Ty<'tcx>, Option<&'static str>), + is_call: bool, + span: impl Fn() -> Span, ) { let feature_def = tcx.sess.target.features_for_correct_vector_abi(); let codegen_attrs = tcx.codegen_fn_attrs(target_feature_def); + let have_feature = |feat: Symbol| { + tcx.sess.unstable_target_features.contains(&feat) + || codegen_attrs.target_features.iter().any(|x| x.name == feat) + }; for arg_abi in abi.args.iter().chain(std::iter::once(&abi.ret)) { let size = arg_abi.layout.size; if uses_vector_registers(&arg_abi.mode, &arg_abi.layout.backend_repr) { @@ -44,15 +46,34 @@ fn do_check_abi<'tcx>( let feature = match feature_def.iter().find(|(bits, _)| size.bits() <= *bits) { Some((_, feature)) => feature, None => { - emit_err(arg_abi.layout.ty, None); + let span = span(); + tcx.emit_node_span_lint( + ABI_UNSUPPORTED_VECTOR_TYPES, + CRATE_HIR_ID, + span, + errors::AbiErrorUnsupportedVectorType { + span, + ty: arg_abi.layout.ty, + is_call, + }, + ); continue; } }; - let feature_sym = Symbol::intern(feature); - if !tcx.sess.unstable_target_features.contains(&feature_sym) - && !codegen_attrs.target_features.iter().any(|x| x.name == feature_sym) - { - emit_err(arg_abi.layout.ty, Some(&feature)); + if !have_feature(Symbol::intern(feature)) { + // Emit error. + let span = span(); + tcx.emit_node_span_lint( + ABI_UNSUPPORTED_VECTOR_TYPES, + CRATE_HIR_ID, + span, + errors::AbiErrorDisabledVectorType { + span, + required_feature: feature, + ty: arg_abi.layout.ty, + is_call, + }, + ); } } } @@ -68,24 +89,13 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) { // function. return; }; - do_check_abi(tcx, abi, instance.def_id(), |ty, required_feature| { - let span = tcx.def_span(instance.def_id()); - if let Some(required_feature) = required_feature { - tcx.emit_node_span_lint( - ABI_UNSUPPORTED_VECTOR_TYPES, - CRATE_HIR_ID, - span, - AbiErrorDisabledVectorTypeDef { span, required_feature, ty }, - ); - } else { - tcx.emit_node_span_lint( - ABI_UNSUPPORTED_VECTOR_TYPES, - CRATE_HIR_ID, - span, - AbiErrorUnsupportedVectorTypeDef { span, ty }, - ); - } - }) + do_check_abi( + tcx, + abi, + instance.def_id(), + /*is_call*/ false, + || tcx.def_span(instance.def_id()), + ) } /// Checks that a call expression does not try to pass a vector-passed argument which requires a @@ -122,23 +132,7 @@ fn check_call_site_abi<'tcx>( // ABI failed to compute; this will not get through codegen. return; }; - do_check_abi(tcx, callee_abi, caller.def_id(), |ty, required_feature| { - if let Some(required_feature) = required_feature { - tcx.emit_node_span_lint( - ABI_UNSUPPORTED_VECTOR_TYPES, - CRATE_HIR_ID, - span, - AbiErrorDisabledVectorTypeCall { span, required_feature, ty }, - ); - } else { - tcx.emit_node_span_lint( - ABI_UNSUPPORTED_VECTOR_TYPES, - CRATE_HIR_ID, - span, - AbiErrorUnsupportedVectorTypeCall { span, ty }, - ); - } - }); + do_check_abi(tcx, callee_abi, caller.def_id(), /*is_call*/ true, || span); } fn check_callees_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, body: &mir::Body<'tcx>) { diff --git a/tests/ui/simd-abi-checks-empty-list.rs b/tests/ui/abi/simd-abi-checks-empty-list.rs similarity index 100% rename from tests/ui/simd-abi-checks-empty-list.rs rename to tests/ui/abi/simd-abi-checks-empty-list.rs diff --git a/tests/ui/simd-abi-checks-empty-list.stderr b/tests/ui/abi/simd-abi-checks-empty-list.stderr similarity index 100% rename from tests/ui/simd-abi-checks-empty-list.stderr rename to tests/ui/abi/simd-abi-checks-empty-list.stderr diff --git a/tests/ui/simd-abi-checks-s390x.rs b/tests/ui/abi/simd-abi-checks-s390x.rs similarity index 100% rename from tests/ui/simd-abi-checks-s390x.rs rename to tests/ui/abi/simd-abi-checks-s390x.rs diff --git a/tests/ui/simd-abi-checks-s390x.z10.stderr b/tests/ui/abi/simd-abi-checks-s390x.z10.stderr similarity index 100% rename from tests/ui/simd-abi-checks-s390x.z10.stderr rename to tests/ui/abi/simd-abi-checks-s390x.z10.stderr diff --git a/tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr similarity index 100% rename from tests/ui/simd-abi-checks-s390x.z13_no_vector.stderr rename to tests/ui/abi/simd-abi-checks-s390x.z13_no_vector.stderr diff --git a/tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr similarity index 100% rename from tests/ui/simd-abi-checks-s390x.z13_soft_float.stderr rename to tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr diff --git a/tests/ui/simd-abi-checks.rs b/tests/ui/abi/simd-abi-checks.rs similarity index 100% rename from tests/ui/simd-abi-checks.rs rename to tests/ui/abi/simd-abi-checks.rs diff --git a/tests/ui/simd-abi-checks.stderr b/tests/ui/abi/simd-abi-checks.stderr similarity index 100% rename from tests/ui/simd-abi-checks.stderr rename to tests/ui/abi/simd-abi-checks.stderr diff --git a/tests/ui/abi/sse-abi-checks.rs b/tests/ui/abi/sse-abi-checks.rs new file mode 100644 index 0000000000000..cb708bea3cae9 --- /dev/null +++ b/tests/ui/abi/sse-abi-checks.rs @@ -0,0 +1,23 @@ +//! Ensure we trigger abi_unsupported_vector_types for target features that are usually enabled +//! 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 +//@ add-core-stubs +//@ build-pass +//@ ignore-pass (test emits codegen-time warnings) +//@ needs-llvm-components: x86 +#![feature(no_core, repr_simd)] +#![no_core] +#![allow(improper_ctypes_definitions)] + +extern crate minicore; +use minicore::*; + +#[repr(simd)] +pub struct SseVector([i64; 2]); + +#[no_mangle] +pub unsafe extern "C" fn f(_: SseVector) { + //~^ this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled + //~| WARNING this was previously accepted by the compiler +} diff --git a/tests/ui/abi/sse-abi-checks.stderr b/tests/ui/abi/sse-abi-checks.stderr new file mode 100644 index 0000000000000..95486f480d256 --- /dev/null +++ b/tests/ui/abi/sse-abi-checks.stderr @@ -0,0 +1,25 @@ +warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled + --> $DIR/sse-simd-abi-checks.rs:20:1 + | +LL | pub unsafe extern "C" fn f(_: SseVector) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here + | + = warning: 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 #116558 + = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) + = note: `#[warn(abi_unsupported_vector_types)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled + --> $DIR/sse-simd-abi-checks.rs:20:1 + | +LL | pub unsafe extern "C" fn f(_: SseVector) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here + | + = warning: 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 #116558 + = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) + = note: `#[warn(abi_unsupported_vector_types)]` on by default + diff --git a/tests/ui/sse-simd-abi-checks.rs b/tests/ui/sse-simd-abi-checks.rs index 396e9bf131880..cb708bea3cae9 100644 --- a/tests/ui/sse-simd-abi-checks.rs +++ b/tests/ui/sse-simd-abi-checks.rs @@ -6,7 +6,7 @@ //@ build-pass //@ ignore-pass (test emits codegen-time warnings) //@ needs-llvm-components: x86 -#![feature(no_core, lang_items, repr_simd)] +#![feature(no_core, repr_simd)] #![no_core] #![allow(improper_ctypes_definitions)] From 83fd16f6258f3ae6fb6c8d6cf06eb4f8c654333e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 18 Feb 2025 17:17:16 +0100 Subject: [PATCH 2/2] vectorcall ABI: error if sse2 is not available --- compiler/rustc_monomorphize/messages.ftl | 14 ++++++ compiler/rustc_monomorphize/src/errors.rs | 13 ++++++ .../src/mono_checks/abi_check.rs | 13 +++++- ...d-abi-checks.rs => simd-abi-checks-avx.rs} | 0 ...ecks.stderr => simd-abi-checks-avx.stderr} | 44 +++++++++---------- ...e-abi-checks.rs => simd-abi-checks-sse.rs} | 0 ...ecks.stderr => simd-abi-checks-sse.stderr} | 4 +- tests/ui/abi/vectorcall-abi-checks.rs | 21 +++++++++ tests/ui/abi/vectorcall-abi-checks.stderr | 18 ++++++++ tests/ui/extern/extern-vectorcall.rs | 1 + tests/ui/sse-simd-abi-checks.rs | 23 ---------- tests/ui/sse-simd-abi-checks.stderr | 25 ----------- 12 files changed, 102 insertions(+), 74 deletions(-) rename tests/ui/abi/{simd-abi-checks.rs => simd-abi-checks-avx.rs} (100%) rename tests/ui/abi/{simd-abi-checks.stderr => simd-abi-checks-avx.stderr} (94%) rename tests/ui/abi/{sse-abi-checks.rs => simd-abi-checks-sse.rs} (100%) rename tests/ui/abi/{sse-abi-checks.stderr => simd-abi-checks-sse.stderr} (94%) create mode 100644 tests/ui/abi/vectorcall-abi-checks.rs create mode 100644 tests/ui/abi/vectorcall-abi-checks.stderr delete mode 100644 tests/ui/sse-simd-abi-checks.rs delete mode 100644 tests/ui/sse-simd-abi-checks.stderr diff --git a/compiler/rustc_monomorphize/messages.ftl b/compiler/rustc_monomorphize/messages.ftl index a83c18cda0e2b..bdeab12ab503b 100644 --- a/compiler/rustc_monomorphize/messages.ftl +++ b/compiler/rustc_monomorphize/messages.ftl @@ -22,6 +22,20 @@ monomorphize_abi_error_unsupported_vector_type = *[false] defined } here +monomorphize_abi_required_target_feature = + this function {$is_call -> + [true] call + *[false] definition + } uses ABI "{$abi}" which requires the `{$required_feature}` target feature, which is not enabled{$is_call -> + [true] {" "}in the caller + *[false] {""} + } + .label = function {$is_call -> + [true] called + *[false] defined + } here + .help = consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable="{$required_feature}")]`) + monomorphize_couldnt_dump_mono_stats = unexpected error occurred while dumping monomorphization stats: {$error} diff --git a/compiler/rustc_monomorphize/src/errors.rs b/compiler/rustc_monomorphize/src/errors.rs index 1cfcd52b66625..8dafbbca905f7 100644 --- a/compiler/rustc_monomorphize/src/errors.rs +++ b/compiler/rustc_monomorphize/src/errors.rs @@ -90,3 +90,16 @@ pub(crate) struct AbiErrorUnsupportedVectorType<'a> { /// Whether this is a problem at a call site or at a declaration. pub is_call: bool, } + +#[derive(Diagnostic)] +#[diag(monomorphize_abi_required_target_feature)] +#[help] +pub(crate) struct AbiRequiredTargetFeature<'a> { + #[primary_span] + #[label] + pub span: Span, + pub required_feature: &'a str, + pub abi: &'a str, + /// Whether this is a problem at a call site or at a declaration. + pub is_call: bool, +} diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index b5a7a81037950..4c8dd933317ef 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -29,12 +29,12 @@ fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool { fn do_check_abi<'tcx>( tcx: TyCtxt<'tcx>, abi: &FnAbi<'tcx, Ty<'tcx>>, - target_feature_def: DefId, + def_id: DefId, is_call: bool, span: impl Fn() -> Span, ) { let feature_def = tcx.sess.target.features_for_correct_vector_abi(); - let codegen_attrs = tcx.codegen_fn_attrs(target_feature_def); + let codegen_attrs = tcx.codegen_fn_attrs(def_id); let have_feature = |feat: Symbol| { tcx.sess.unstable_target_features.contains(&feat) || codegen_attrs.target_features.iter().any(|x| x.name == feat) @@ -77,6 +77,15 @@ fn do_check_abi<'tcx>( } } } + // The `vectorcall` ABI is special in that it requires SSE2 no matter which types are being passed. + if abi.conv == Conv::X86VectorCall && !have_feature(sym::sse2) { + tcx.dcx().emit_err(errors::AbiRequiredTargetFeature { + span: span(), + required_feature: "sse2", + abi: "vectorcall", + is_call, + }); + } } /// Checks that the ABI of a given instance of a function does not contain vector-passed arguments diff --git a/tests/ui/abi/simd-abi-checks.rs b/tests/ui/abi/simd-abi-checks-avx.rs similarity index 100% rename from tests/ui/abi/simd-abi-checks.rs rename to tests/ui/abi/simd-abi-checks-avx.rs diff --git a/tests/ui/abi/simd-abi-checks.stderr b/tests/ui/abi/simd-abi-checks-avx.stderr similarity index 94% rename from tests/ui/abi/simd-abi-checks.stderr rename to tests/ui/abi/simd-abi-checks-avx.stderr index a849993a1663b..0dddc7dfa1c1b 100644 --- a/tests/ui/abi/simd-abi-checks.stderr +++ b/tests/ui/abi/simd-abi-checks-avx.stderr @@ -1,5 +1,5 @@ warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:64:11 + --> $DIR/simd-abi-checks-avx.rs:64:11 | LL | f(g()); | ^^^ function called here @@ -10,7 +10,7 @@ LL | f(g()); = note: `#[warn(abi_unsupported_vector_types)]` on by default warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:64:9 + --> $DIR/simd-abi-checks-avx.rs:64:9 | LL | f(g()); | ^^^^^^ function called here @@ -20,7 +20,7 @@ LL | f(g()); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:72:14 + --> $DIR/simd-abi-checks-avx.rs:72:14 | LL | gavx(favx()); | ^^^^^^ function called here @@ -30,7 +30,7 @@ LL | gavx(favx()); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:72:9 + --> $DIR/simd-abi-checks-avx.rs:72:9 | LL | gavx(favx()); | ^^^^^^^^^^^^ function called here @@ -40,7 +40,7 @@ LL | gavx(favx()); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:84:19 + --> $DIR/simd-abi-checks-avx.rs:84:19 | LL | w(Wrapper(g())); | ^^^ function called here @@ -50,7 +50,7 @@ LL | w(Wrapper(g())); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:84:9 + --> $DIR/simd-abi-checks-avx.rs:84:9 | LL | w(Wrapper(g())); | ^^^^^^^^^^^^^^^ function called here @@ -60,7 +60,7 @@ LL | w(Wrapper(g())); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:100:9 + --> $DIR/simd-abi-checks-avx.rs:100:9 | LL | some_extern(); | ^^^^^^^^^^^^^ function called here @@ -70,7 +70,7 @@ LL | some_extern(); = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:27:1 + --> $DIR/simd-abi-checks-avx.rs:27:1 | LL | unsafe extern "C" fn g() -> __m256 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -80,7 +80,7 @@ LL | unsafe extern "C" fn g() -> __m256 { = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:21:1 + --> $DIR/simd-abi-checks-avx.rs:21:1 | LL | unsafe extern "C" fn f(_: __m256) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -90,7 +90,7 @@ LL | unsafe extern "C" fn f(_: __m256) { = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:15:1 + --> $DIR/simd-abi-checks-avx.rs:15:1 | LL | unsafe extern "C" fn w(_: Wrapper) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -100,7 +100,7 @@ LL | unsafe extern "C" fn w(_: Wrapper) { = help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`) warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:57:8 + --> $DIR/simd-abi-checks-avx.rs:57:8 | LL | || g() | ^^^ function called here @@ -113,7 +113,7 @@ warning: 11 warnings emitted Future incompatibility report: Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:64:11 + --> $DIR/simd-abi-checks-avx.rs:64:11 | LL | f(g()); | ^^^ function called here @@ -125,7 +125,7 @@ LL | f(g()); Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:64:9 + --> $DIR/simd-abi-checks-avx.rs:64:9 | LL | f(g()); | ^^^^^^ function called here @@ -137,7 +137,7 @@ LL | f(g()); Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:72:14 + --> $DIR/simd-abi-checks-avx.rs:72:14 | LL | gavx(favx()); | ^^^^^^ function called here @@ -149,7 +149,7 @@ LL | gavx(favx()); Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:72:9 + --> $DIR/simd-abi-checks-avx.rs:72:9 | LL | gavx(favx()); | ^^^^^^^^^^^^ function called here @@ -161,7 +161,7 @@ LL | gavx(favx()); Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:84:19 + --> $DIR/simd-abi-checks-avx.rs:84:19 | LL | w(Wrapper(g())); | ^^^ function called here @@ -173,7 +173,7 @@ LL | w(Wrapper(g())); Future breakage diagnostic: warning: this function call uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:84:9 + --> $DIR/simd-abi-checks-avx.rs:84:9 | LL | w(Wrapper(g())); | ^^^^^^^^^^^^^^^ function called here @@ -185,7 +185,7 @@ LL | w(Wrapper(g())); Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:100:9 + --> $DIR/simd-abi-checks-avx.rs:100:9 | LL | some_extern(); | ^^^^^^^^^^^^^ function called here @@ -197,7 +197,7 @@ LL | some_extern(); Future breakage diagnostic: warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:27:1 + --> $DIR/simd-abi-checks-avx.rs:27:1 | LL | unsafe extern "C" fn g() -> __m256 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -209,7 +209,7 @@ LL | unsafe extern "C" fn g() -> __m256 { Future breakage diagnostic: warning: this function definition uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:21:1 + --> $DIR/simd-abi-checks-avx.rs:21:1 | LL | unsafe extern "C" fn f(_: __m256) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -221,7 +221,7 @@ LL | unsafe extern "C" fn f(_: __m256) { Future breakage diagnostic: warning: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled - --> $DIR/simd-abi-checks.rs:15:1 + --> $DIR/simd-abi-checks-avx.rs:15:1 | LL | unsafe extern "C" fn w(_: Wrapper) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here @@ -233,7 +233,7 @@ LL | unsafe extern "C" fn w(_: Wrapper) { Future breakage diagnostic: warning: this function call uses SIMD vector type `std::arch::x86_64::__m256` which (with the chosen ABI) requires the `avx` target feature, which is not enabled in the caller - --> $DIR/simd-abi-checks.rs:57:8 + --> $DIR/simd-abi-checks-avx.rs:57:8 | LL | || g() | ^^^ function called here diff --git a/tests/ui/abi/sse-abi-checks.rs b/tests/ui/abi/simd-abi-checks-sse.rs similarity index 100% rename from tests/ui/abi/sse-abi-checks.rs rename to tests/ui/abi/simd-abi-checks-sse.rs diff --git a/tests/ui/abi/sse-abi-checks.stderr b/tests/ui/abi/simd-abi-checks-sse.stderr similarity index 94% rename from tests/ui/abi/sse-abi-checks.stderr rename to tests/ui/abi/simd-abi-checks-sse.stderr index 95486f480d256..c0f2e6e1e1b14 100644 --- a/tests/ui/abi/sse-abi-checks.stderr +++ b/tests/ui/abi/simd-abi-checks-sse.stderr @@ -1,5 +1,5 @@ warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-simd-abi-checks.rs:20:1 + --> $DIR/simd-abi-checks-sse.rs:20: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 SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-simd-abi-checks.rs:20:1 + --> $DIR/simd-abi-checks-sse.rs:20:1 | LL | pub unsafe extern "C" fn f(_: SseVector) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here diff --git a/tests/ui/abi/vectorcall-abi-checks.rs b/tests/ui/abi/vectorcall-abi-checks.rs new file mode 100644 index 0000000000000..d83bbffa745f8 --- /dev/null +++ b/tests/ui/abi/vectorcall-abi-checks.rs @@ -0,0 +1,21 @@ +//@ add-core-stubs +//@ compile-flags: --crate-type=rlib --target=i586-unknown-linux-gnu -C target-feature=-sse,-sse2 +//@ build-fail +//@ ignore-pass (test emits codegen-time errors) +//@ needs-llvm-components: x86 +#![feature(no_core, abi_vectorcall)] +#![no_core] + +extern crate minicore; +use minicore::*; + +#[no_mangle] +pub extern "vectorcall" fn f() { + //~^ ABI "vectorcall" which requires the `sse2` target feature +} + +#[no_mangle] +pub fn call_site() { + f(); + //~^ ABI "vectorcall" which requires the `sse2` target feature +} diff --git a/tests/ui/abi/vectorcall-abi-checks.stderr b/tests/ui/abi/vectorcall-abi-checks.stderr new file mode 100644 index 0000000000000..671ebc25b42a0 --- /dev/null +++ b/tests/ui/abi/vectorcall-abi-checks.stderr @@ -0,0 +1,18 @@ +error: this function definition uses ABI "vectorcall" which requires the `sse2` target feature, which is not enabled + --> $DIR/vectorcall-abi-checks.rs:13:1 + | +LL | pub extern "vectorcall" fn f() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here + | + = help: consider enabling it globally (`-C target-feature=+sse2`) or locally (`#[target_feature(enable="sse2")]`) + +error: this function call uses ABI "vectorcall" which requires the `sse2` target feature, which is not enabled in the caller + --> $DIR/vectorcall-abi-checks.rs:19:5 + | +LL | f(); + | ^^^ function called here + | + = help: consider enabling it globally (`-C target-feature=+sse2`) or locally (`#[target_feature(enable="sse2")]`) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/extern/extern-vectorcall.rs b/tests/ui/extern/extern-vectorcall.rs index c0d872bc14beb..fb23c4cd5b549 100644 --- a/tests/ui/extern/extern-vectorcall.rs +++ b/tests/ui/extern/extern-vectorcall.rs @@ -2,6 +2,7 @@ //@ revisions: x64 x32 //@ [x64]only-x86_64 //@ [x32]only-x86 +//@ [x32]compile-flags: -Ctarget-feature=+sse2 #![feature(abi_vectorcall)] diff --git a/tests/ui/sse-simd-abi-checks.rs b/tests/ui/sse-simd-abi-checks.rs deleted file mode 100644 index cb708bea3cae9..0000000000000 --- a/tests/ui/sse-simd-abi-checks.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Ensure we trigger abi_unsupported_vector_types for target features that are usually enabled -//! 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 -//@ add-core-stubs -//@ build-pass -//@ ignore-pass (test emits codegen-time warnings) -//@ needs-llvm-components: x86 -#![feature(no_core, repr_simd)] -#![no_core] -#![allow(improper_ctypes_definitions)] - -extern crate minicore; -use minicore::*; - -#[repr(simd)] -pub struct SseVector([i64; 2]); - -#[no_mangle] -pub unsafe extern "C" fn f(_: SseVector) { - //~^ this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - //~| WARNING this was previously accepted by the compiler -} diff --git a/tests/ui/sse-simd-abi-checks.stderr b/tests/ui/sse-simd-abi-checks.stderr deleted file mode 100644 index 95486f480d256..0000000000000 --- a/tests/ui/sse-simd-abi-checks.stderr +++ /dev/null @@ -1,25 +0,0 @@ -warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-simd-abi-checks.rs:20:1 - | -LL | pub unsafe extern "C" fn f(_: SseVector) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here - | - = warning: 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 #116558 - = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default - -warning: 1 warning emitted - -Future incompatibility report: Future breakage diagnostic: -warning: this function definition uses SIMD vector type `SseVector` which (with the chosen ABI) requires the `sse` target feature, which is not enabled - --> $DIR/sse-simd-abi-checks.rs:20:1 - | -LL | pub unsafe extern "C" fn f(_: SseVector) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here - | - = warning: 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 #116558 - = help: consider enabling it globally (`-C target-feature=+sse`) or locally (`#[target_feature(enable="sse")]`) - = note: `#[warn(abi_unsupported_vector_types)]` on by default -