Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions compiler/rustc_monomorphize/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,23 @@ pub(crate) struct EncounteredErrorWhileInstantiatingGlobalAsm {
pub(crate) struct StartNotFound;

#[derive(Diagnostic)]
#[diag("this function {$is_call ->
[true] call
*[false] definition
} uses {$is_scalable ->
[true] scalable
*[false] 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] {\"\"}
}")]
#[diag(
"this function {$is_call ->
[true] call
*[false] definition
} requires the `{$required_feature}` target feature, which is not enabled{$is_call ->
[true] {\" \"}in the caller
*[false] {\"\"}
}"
)]
#[note(
"the function has type `{$ty}` in its signature, which is passed in {$is_scalable ->
[true] scalable
*[false] SIMD
} vector registers under the \"{$abi}\" ABI"
)]
#[help(
"consider enabling it globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
"consider enabling the missing target feature globally (`-C target-feature=+{$required_feature}`) or locally (`#[target_feature(enable=\"{$required_feature}\")]`)"
)]
pub(crate) struct AbiErrorDisabledVectorType<'a> {
#[primary_span]
Expand All @@ -124,6 +129,7 @@ pub(crate) struct AbiErrorDisabledVectorType<'a> {
)]
pub span: Span,
pub required_feature: &'a str,
pub abi: String,
pub ty: Ty<'a>,
/// Whether this is a problem at a call site or at a declaration.
pub is_call: bool,
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_monomorphize/src/mono_checks/abi_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fn do_check_simd_vector_abi<'tcx>(
tcx.dcx().emit_err(diagnostics::AbiErrorDisabledVectorType {
span,
required_feature: feature,
abi: abi.conv.to_string(),
ty: arg_abi.layout.ty,
is_call,
is_scalable: false,
Expand All @@ -101,6 +102,7 @@ fn do_check_simd_vector_abi<'tcx>(
tcx.dcx().emit_err(diagnostics::AbiErrorDisabledVectorType {
span,
required_feature,
abi: abi.conv.to_string(),
ty: arg_abi.layout.ty,
is_call,
is_scalable: true,
Expand Down Expand Up @@ -170,12 +172,8 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
tcx.dcx().delayed_bug("ABI computation failure should lead to compilation failure");
return;
};
// Unlike the call-site check, we do also check "Rust" ABI functions here.
// This should never trigger, *except* if we start making use of vector registers
// for the "Rust" ABI and the user disables those vector registers (which should trigger a
// warning as that's clearly disabling a "required" target feature for this target).
// Using such a function is where disabling the vector register actually can start leading
// to soundness issues, so erroring here seems good.
// Unlike the call-site check, we do also check "Rust" ABI functions here. This can actually
// trigger due to scalable vectors being require for the "Rust" ABI for some types.
let loc = || {
let def_id = instance.def_id();
(
Expand Down
55 changes: 33 additions & 22 deletions tests/ui/abi/simd-abi-checks-avx.stderr
Original file line number Diff line number Diff line change
@@ -1,90 +1,101 @@
error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:59:11
|
LL | f(g());
| ^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:59:9
|
LL | f(g());
| ^^^^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:65:14
|
LL | gavx(favx());
| ^^^^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:65:9
|
LL | gavx(favx());
| ^^^^^^^^^^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:75:19
|
LL | w(Wrapper(g()));
| ^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:75:9
|
LL | w(Wrapper(g()));
| ^^^^^^^^^^^^^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `Wrapper` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:89:9
|
LL | some_extern();
| ^^^^^^^^^^^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function definition requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:24:1
|
LL | unsafe extern "C" fn g() -> __m256 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function definition requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:19:1
|
LL | unsafe extern "C" fn f(_: __m256) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: this function definition uses SIMD vector type `Wrapper` which (with the chosen ABI) requires the `avx` target feature, which is not enabled
error: this function definition requires the `avx` target feature, which is not enabled
--> $DIR/simd-abi-checks-avx.rs:14:1
|
LL | unsafe extern "C" fn w(_: Wrapper) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `Wrapper` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

error: 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
error: this function call requires the `avx` target feature, which is not enabled in the caller
--> $DIR/simd-abi-checks-avx.rs:53:8
|
LL | || g()
| ^^^ function called here
|
= help: consider enabling it globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)
= note: the function has type `std::arch::x86_64::__m256` in its signature, which is passed in SIMD vector registers under the "C" ABI
= help: consider enabling the missing target feature globally (`-C target-feature=+avx`) or locally (`#[target_feature(enable="avx")]`)

note: the above error was encountered while instantiating `fn in_closure::{closure#0}`
--> $DIR/simd-abi-checks-avx.rs:81:9
Expand Down
Loading
Loading