Skip to content

Commit 56772c6

Browse files
committed
Disable simd vector abi checks for unadjusted ABI
1 parent 385036e commit 56772c6

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler/rustc_monomorphize/src/mono_checks/abi_check.rs

Lines changed: 11 additions & 2 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;
@@ -153,6 +153,13 @@ fn do_check_wasm_abi<'tcx>(
153153
/// or return values for which the corresponding target feature is not enabled.
154154
fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
155155
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+
}
156163
let Ok(abi) = tcx.fn_abi_of_instance(typing_env.as_query_input((instance, ty::List::empty())))
157164
else {
158165
// An error will be reported during codegen if we cannot determine the ABI of this
@@ -178,8 +185,10 @@ fn check_call_site_abi<'tcx>(
178185
caller: InstanceKind<'tcx>,
179186
loc: impl Fn() -> (Span, HirId) + Copy,
180187
) {
181-
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 {
182190
// we directly handle the soundness of Rust ABIs
191+
// we disable all checks for the unadjusted abi
183192
return;
184193
}
185194
let typing_env = ty::TypingEnv::fully_monomorphized();

0 commit comments

Comments
 (0)