@@ -24,6 +24,7 @@ use rustc_span::source_map::Spanned;
2424use rustc_target:: callconv:: { FnAbi , PassMode } ;
2525use smallvec:: { SmallVec , smallvec} ;
2626
27+ pub ( crate ) use self :: pass_mode:: adjust_fn_abi_for_rust_abi_mistakes;
2728use self :: pass_mode:: * ;
2829pub ( crate ) use self :: returning:: codegen_return;
2930use crate :: base:: codegen_unwind_terminate;
@@ -85,7 +86,10 @@ pub(crate) fn get_function_sig<'tcx>(
8586 clif_sig_from_fn_abi (
8687 tcx,
8788 default_call_conv,
88- & FullyMonomorphizedLayoutCx ( tcx) . fn_abi_of_instance ( inst, ty:: List :: empty ( ) ) ,
89+ & adjust_fn_abi_for_rust_abi_mistakes (
90+ tcx,
91+ FullyMonomorphizedLayoutCx ( tcx) . fn_abi_of_instance ( inst, ty:: List :: empty ( ) ) ,
92+ ) ,
8993 )
9094}
9195
@@ -461,11 +465,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
461465 let extra_args = fx. tcx . mk_type_list_from_iter (
462466 extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
463467 ) ;
464- let fn_abi = if let Some ( instance) = instance {
465- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
466- } else {
467- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
468- } ;
468+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
469+ fx. tcx ,
470+ if let Some ( instance) = instance {
471+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
472+ } else {
473+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
474+ } ,
475+ ) ;
469476
470477 let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
471478 true
@@ -736,8 +743,11 @@ pub(crate) fn codegen_drop<'tcx>(
736743 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
737744 args : drop_instance. args ,
738745 } ;
739- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
740- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
746+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
747+ fx. tcx ,
748+ FullyMonomorphizedLayoutCx ( fx. tcx )
749+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
750+ ) ;
741751
742752 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
743753 let sig = fx. bcx . import_signature ( sig) ;
@@ -753,8 +763,11 @@ pub(crate) fn codegen_drop<'tcx>(
753763 _ => {
754764 assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
755765
756- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
757- . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ;
766+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
767+ fx. tcx ,
768+ FullyMonomorphizedLayoutCx ( fx. tcx )
769+ . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ,
770+ ) ;
758771
759772 let arg_value = drop_place. place_ref (
760773 fx,
0 commit comments