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 ;
@@ -31,10 +31,16 @@ fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool {
31
31
fn do_check_simd_vector_abi < ' tcx > (
32
32
tcx : TyCtxt < ' tcx > ,
33
33
abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
34
+ extern_abi : ExternAbi ,
34
35
def_id : DefId ,
35
36
is_call : bool ,
36
37
loc : impl Fn ( ) -> ( Span , HirId ) ,
37
38
) {
39
+ // we skip this check for the "unadjusted" abi
40
+ if extern_abi == ExternAbi :: Unadjusted {
41
+ return ;
42
+ }
43
+
38
44
// We check this on all functions, including those using the "Rust" ABI.
39
45
// For the "Rust" ABI it would be a bug if the lint ever triggered, but better safe than sorry.
40
46
let feature_def = tcx. sess . target . features_for_correct_vector_abi ( ) ;
@@ -49,11 +55,6 @@ fn do_check_simd_vector_abi<'tcx>(
49
55
// Find the first feature that provides at least this vector size.
50
56
let feature = match feature_def. iter ( ) . find ( |( bits, _) | size. bits ( ) <= * bits) {
51
57
Some ( ( _, feature) ) => feature,
52
- None if matches ! ( & * tcx. sess. target. arch, "x86" | "x86_64" )
53
- && size. bits ( ) == 8192 =>
54
- {
55
- "amx-tile"
56
- }
57
58
None => {
58
59
let ( span, _hir_id) = loc ( ) ;
59
60
tcx. dcx ( ) . emit_err ( errors:: AbiErrorUnsupportedVectorType {
@@ -171,7 +172,8 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
171
172
def_id. as_local ( ) . map ( |did| tcx. local_def_id_to_hir_id ( did) ) . unwrap_or ( CRATE_HIR_ID ) ,
172
173
)
173
174
} ;
174
- do_check_simd_vector_abi ( tcx, abi, instance. def_id ( ) , /*is_call*/ false , loc) ;
175
+ let extern_abi = instance. ty ( tcx, typing_env) . fn_sig ( tcx) . abi ( ) ;
176
+ do_check_simd_vector_abi ( tcx, abi, extern_abi, instance. def_id ( ) , /*is_call*/ false , loc) ;
175
177
do_check_wasm_abi ( tcx, abi, /*is_call*/ false , loc) ;
176
178
}
177
179
@@ -209,7 +211,9 @@ fn check_call_site_abi<'tcx>(
209
211
// ABI failed to compute; this will not get through codegen.
210
212
return ;
211
213
} ;
212
- do_check_simd_vector_abi ( tcx, callee_abi, caller. def_id ( ) , /*is_call*/ true , loc) ;
214
+
215
+ let extern_abi = callee. fn_sig ( tcx) . abi ( ) ;
216
+ do_check_simd_vector_abi ( tcx, callee_abi, extern_abi, caller. def_id ( ) , /*is_call*/ true , loc) ;
213
217
do_check_wasm_abi ( tcx, callee_abi, /*is_call*/ true , loc) ;
214
218
}
215
219
0 commit comments