@@ -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
@@ -450,11 +454,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
450454 let extra_args = fx. tcx . mk_type_list_from_iter (
451455 extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
452456 ) ;
453- let fn_abi = if let Some ( instance) = instance {
454- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
455- } else {
456- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
457- } ;
457+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
458+ fx. tcx ,
459+ if let Some ( instance) = instance {
460+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
461+ } else {
462+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
463+ } ,
464+ ) ;
458465
459466 let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
460467 true
@@ -734,8 +741,11 @@ pub(crate) fn codegen_drop<'tcx>(
734741 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
735742 args : drop_instance. args ,
736743 } ;
737- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
738- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
744+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
745+ fx. tcx ,
746+ FullyMonomorphizedLayoutCx ( fx. tcx )
747+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
748+ ) ;
739749
740750 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
741751 let sig = fx. bcx . import_signature ( sig) ;
@@ -777,8 +787,11 @@ pub(crate) fn codegen_drop<'tcx>(
777787 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
778788 args : drop_instance. args ,
779789 } ;
780- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
781- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
790+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
791+ fx. tcx ,
792+ FullyMonomorphizedLayoutCx ( fx. tcx )
793+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
794+ ) ;
782795
783796 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
784797 let sig = fx. bcx . import_signature ( sig) ;
@@ -787,8 +800,11 @@ pub(crate) fn codegen_drop<'tcx>(
787800 _ => {
788801 assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
789802
790- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
791- . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ;
803+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
804+ fx. tcx ,
805+ FullyMonomorphizedLayoutCx ( fx. tcx )
806+ . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ,
807+ ) ;
792808
793809 let arg_value = drop_place. place_ref (
794810 fx,
0 commit comments