@@ -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
@@ -458,11 +462,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
458462 let extra_args = fx. tcx . mk_type_list_from_iter (
459463 extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
460464 ) ;
461- let fn_abi = if let Some ( instance) = instance {
462- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
463- } else {
464- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
465- } ;
465+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
466+ fx. tcx ,
467+ if let Some ( instance) = instance {
468+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
469+ } else {
470+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
471+ } ,
472+ ) ;
466473
467474 let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
468475 true
@@ -742,8 +749,11 @@ pub(crate) fn codegen_drop<'tcx>(
742749 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
743750 args : drop_instance. args ,
744751 } ;
745- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
746- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
752+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
753+ fx. tcx ,
754+ FullyMonomorphizedLayoutCx ( fx. tcx )
755+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
756+ ) ;
747757
748758 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
749759 let sig = fx. bcx . import_signature ( sig) ;
@@ -785,8 +795,11 @@ pub(crate) fn codegen_drop<'tcx>(
785795 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
786796 args : drop_instance. args ,
787797 } ;
788- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
789- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
798+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
799+ fx. tcx ,
800+ FullyMonomorphizedLayoutCx ( fx. tcx )
801+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
802+ ) ;
790803
791804 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
792805 let sig = fx. bcx . import_signature ( sig) ;
@@ -795,8 +808,11 @@ pub(crate) fn codegen_drop<'tcx>(
795808 _ => {
796809 assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
797810
798- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
799- . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ;
811+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
812+ fx. tcx ,
813+ FullyMonomorphizedLayoutCx ( fx. tcx )
814+ . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ,
815+ ) ;
800816
801817 let arg_value = drop_place. place_ref (
802818 fx,
0 commit comments