@@ -35,8 +35,6 @@ fn do_check_simd_vector_abi<'tcx>(
3535 is_call : bool ,
3636 loc : impl Fn ( ) -> ( Span , HirId ) ,
3737) {
38- // We check this on all functions, including those using the "Rust" ABI.
39- // For the "Rust" ABI it would be a bug if the lint ever triggered, but better safe than sorry.
4038 let feature_def = tcx. sess . target . features_for_correct_vector_abi ( ) ;
4139 let codegen_attrs = tcx. codegen_fn_attrs ( def_id) ;
4240 let have_feature = |feat : Symbol | {
@@ -123,8 +121,9 @@ fn do_check_wasm_abi<'tcx>(
123121 is_call : bool ,
124122 loc : impl Fn ( ) -> ( Span , HirId ) ,
125123) {
126- // Only proceed for `extern "C" fn` on wasm32-unknown-unknown (same check as what `adjust_for_foreign_abi` uses to call `compute_wasm_abi_info`),
127- // and only proceed if `wasm_c_abi_opt` indicates we should emit the lint.
124+ // Only proceed for `extern "C" fn` on wasm32-unknown-unknown (same check as what
125+ // `adjust_for_foreign_abi` uses to call `compute_wasm_abi_info`), and only proceed if
126+ // `wasm_c_abi_opt` indicates we should emit the lint.
128127 if !( tcx. sess . target . arch == "wasm32"
129128 && tcx. sess . target . os == "unknown"
130129 && tcx. wasm_c_abi_opt ( ) == WasmCAbi :: Legacy { with_lint : true }
@@ -157,8 +156,15 @@ fn check_instance_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) {
157156 else {
158157 // An error will be reported during codegen if we cannot determine the ABI of this
159158 // function.
159+ tcx. dcx ( ) . delayed_bug ( "ABI computation failure should lead to compilation failure" ) ;
160160 return ;
161161 } ;
162+ // Unlike the call-site check, we do also check "Rust" ABI functions here.
163+ // This should never trigger, *except* if we start making use of vector registers
164+ // for the "Rust" ABI and the user disables those vector registers (which should trigger a
165+ // warning as that's clearly disabling a "required" target feature for this target).
166+ // Using such a function is where disabling the vector register actually can start leading
167+ // to soundness issues, so erroring here seems good.
162168 let loc = || {
163169 let def_id = instance. def_id ( ) ;
164170 (
@@ -179,7 +185,8 @@ fn check_call_site_abi<'tcx>(
179185 loc : impl Fn ( ) -> ( Span , HirId ) + Copy ,
180186) {
181187 if callee. fn_sig ( tcx) . abi ( ) . is_rustic_abi ( ) {
182- // we directly handle the soundness of Rust ABIs
188+ // We directly handle the soundness of Rust ABIs -- so let's skip the majority of
189+ // call sites to avoid a perf regression.
183190 return ;
184191 }
185192 let typing_env = ty:: TypingEnv :: fully_monomorphized ( ) ;
0 commit comments