1
1
//! This module ensures that if a function's ABI requires a particular target feature,
2
2
//! 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 } ;
4
4
use rustc_hir:: { CRATE_HIR_ID , HirId } ;
5
5
use rustc_middle:: mir:: { self , Location , traversal} ;
6
6
use rustc_middle:: ty:: layout:: LayoutCx ;
@@ -49,11 +49,6 @@ fn do_check_simd_vector_abi<'tcx>(
49
49
// Find the first feature that provides at least this vector size.
50
50
let feature = match feature_def. iter ( ) . find ( |( bits, _) | size. bits ( ) <= * bits) {
51
51
Some ( ( _, feature) ) => feature,
52
- None if matches ! ( & * tcx. sess. target. arch, "x86" | "x86_64" )
53
- && size. bits ( ) == 8192 =>
54
- {
55
- "amx-tile"
56
- }
57
52
None => {
58
53
let ( span, _hir_id) = loc ( ) ;
59
54
tcx. dcx ( ) . emit_err ( errors:: AbiErrorUnsupportedVectorType {
@@ -158,6 +153,13 @@ fn do_check_wasm_abi<'tcx>(
158
153
/// or return values for which the corresponding target feature is not enabled.
159
154
fn check_instance_abi < ' tcx > ( tcx : TyCtxt < ' tcx > , instance : Instance < ' tcx > ) {
160
155
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
+ }
161
163
let Ok ( abi) = tcx. fn_abi_of_instance ( typing_env. as_query_input ( ( instance, ty:: List :: empty ( ) ) ) )
162
164
else {
163
165
// 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>(
183
185
caller : InstanceKind < ' tcx > ,
184
186
loc : impl Fn ( ) -> ( Span , HirId ) + Copy ,
185
187
) {
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 {
187
190
// we directly handle the soundness of Rust ABIs
191
+ // we disable all checks for the unadjusted abi
188
192
return ;
189
193
}
190
194
let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
0 commit comments