@@ -21,6 +21,7 @@ use rustc_session::Session;
2121use rustc_span:: source_map:: Spanned ;
2222use rustc_target:: callconv:: { Conv , FnAbi , PassMode } ;
2323
24+ pub ( crate ) use self :: pass_mode:: adjust_fn_abi_for_rust_abi_mistakes;
2425use self :: pass_mode:: * ;
2526pub ( crate ) use self :: returning:: codegen_return;
2627use crate :: prelude:: * ;
@@ -80,7 +81,10 @@ pub(crate) fn get_function_sig<'tcx>(
8081 clif_sig_from_fn_abi (
8182 tcx,
8283 default_call_conv,
83- & FullyMonomorphizedLayoutCx ( tcx) . fn_abi_of_instance ( inst, ty:: List :: empty ( ) ) ,
84+ & adjust_fn_abi_for_rust_abi_mistakes (
85+ tcx,
86+ FullyMonomorphizedLayoutCx ( tcx) . fn_abi_of_instance ( inst, ty:: List :: empty ( ) ) ,
87+ ) ,
8488 )
8589}
8690
@@ -451,11 +455,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
451455 let extra_args = fx. tcx . mk_type_list_from_iter (
452456 extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
453457 ) ;
454- let fn_abi = if let Some ( instance) = instance {
455- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
456- } else {
457- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
458- } ;
458+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
459+ fx. tcx ,
460+ if let Some ( instance) = instance {
461+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
462+ } else {
463+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
464+ } ,
465+ ) ;
459466
460467 let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
461468 true
@@ -735,8 +742,11 @@ pub(crate) fn codegen_drop<'tcx>(
735742 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
736743 args : drop_instance. args ,
737744 } ;
738- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
739- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
745+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
746+ fx. tcx ,
747+ FullyMonomorphizedLayoutCx ( fx. tcx )
748+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
749+ ) ;
740750
741751 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
742752 let sig = fx. bcx . import_signature ( sig) ;
@@ -778,8 +788,11 @@ pub(crate) fn codegen_drop<'tcx>(
778788 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
779789 args : drop_instance. args ,
780790 } ;
781- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
782- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
791+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
792+ fx. tcx ,
793+ FullyMonomorphizedLayoutCx ( fx. tcx )
794+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
795+ ) ;
783796
784797 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
785798 let sig = fx. bcx . import_signature ( sig) ;
@@ -788,8 +801,11 @@ pub(crate) fn codegen_drop<'tcx>(
788801 _ => {
789802 assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
790803
791- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
792- . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ;
804+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
805+ fx. tcx ,
806+ FullyMonomorphizedLayoutCx ( fx. tcx )
807+ . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ,
808+ ) ;
793809
794810 let arg_value = drop_place. place_ref (
795811 fx,
0 commit comments