Skip to content

Commit 2bdff9e

Browse files
committed
Disable vector abi check for the unadjusted abi
1 parent b75d396 commit 2bdff9e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This module ensures that if a function's ABI requires a particular target feature,
22
//! that target feature is enabled both on the callee and all callers.
3-
use rustc_abi::{BackendRepr, RegKind};
3+
use rustc_abi::{BackendRepr, ExternAbi, RegKind};
44
use rustc_hir::{CRATE_HIR_ID, HirId};
55
use rustc_middle::mir::{self, Location, traversal};
66
use rustc_middle::ty::layout::LayoutCx;
@@ -49,11 +49,6 @@ fn do_check_simd_vector_abi<'tcx>(
4949
// Find the first feature that provides at least this vector size.
5050
let feature = match feature_def.iter().find(|(bits, _)| size.bits() <= *bits) {
5151
Some((_, feature)) => feature,
52-
None if matches!(&*tcx.sess.target.arch, "x86" | "x86_64")
53-
&& size.bits() == 8192 =>
54-
{
55-
"amx-tile"
56-
}
5752
None => {
5853
let (span, _hir_id) = loc();
5954
tcx.dcx().emit_err(errors::AbiErrorUnsupportedVectorType {
@@ -158,6 +153,13 @@ fn do_check_wasm_abi<'tcx>(
158153
/// or return values for which the corresponding target feature is not enabled.
159154
fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
160155
let typing_env = ty::TypingEnv::fully_monomorphized();
156+
let ty = instance.ty(tcx, typing_env);
157+
if ty.is_fn() {
158+
if ty.fn_sig(tcx).abi() == ExternAbi::Unadjusted {
159+
// we disable all checks for the unadjusted abi
160+
return;
161+
}
162+
}
161163
let Ok(abi) = tcx.fn_abi_of_instance(typing_env.as_query_input((instance, ty::List::empty())))
162164
else {
163165
// An error will be reported during codegen if we cannot determine the ABI of this
@@ -183,8 +185,10 @@ fn check_call_site_abi<'tcx>(
183185
caller: InstanceKind<'tcx>,
184186
loc: impl Fn() -> (Span, HirId) + Copy,
185187
) {
186-
if callee.fn_sig(tcx).abi().is_rustic_abi() {
188+
let extern_abi = callee.fn_sig(tcx).abi();
189+
if extern_abi.is_rustic_abi() || extern_abi == ExternAbi::Unadjusted {
187190
// we directly handle the soundness of Rust ABIs
191+
// we disable all checks for the unadjusted abi
188192
return;
189193
}
190194
let typing_env = ty::TypingEnv::fully_monomorphized();

0 commit comments

Comments
 (0)