@@ -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
@@ -453,11 +457,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
453457 let extra_args = fx. tcx . mk_type_list_from_iter (
454458 extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
455459 ) ;
456- let fn_abi = if let Some ( instance) = instance {
457- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
458- } else {
459- FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
460- } ;
460+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
461+ fx. tcx ,
462+ if let Some ( instance) = instance {
463+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_instance ( instance, extra_args)
464+ } else {
465+ FullyMonomorphizedLayoutCx ( fx. tcx ) . fn_abi_of_fn_ptr ( fn_sig, extra_args)
466+ } ,
467+ ) ;
461468
462469 let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
463470 true
@@ -737,8 +744,11 @@ pub(crate) fn codegen_drop<'tcx>(
737744 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
738745 args : drop_instance. args ,
739746 } ;
740- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
741- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
747+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
748+ fx. tcx ,
749+ FullyMonomorphizedLayoutCx ( fx. tcx )
750+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
751+ ) ;
742752
743753 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
744754 let sig = fx. bcx . import_signature ( sig) ;
@@ -780,8 +790,11 @@ pub(crate) fn codegen_drop<'tcx>(
780790 def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
781791 args : drop_instance. args ,
782792 } ;
783- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
784- . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ;
793+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
794+ fx. tcx ,
795+ FullyMonomorphizedLayoutCx ( fx. tcx )
796+ . fn_abi_of_instance ( virtual_drop, ty:: List :: empty ( ) ) ,
797+ ) ;
785798
786799 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
787800 let sig = fx. bcx . import_signature ( sig) ;
@@ -790,8 +803,11 @@ pub(crate) fn codegen_drop<'tcx>(
790803 _ => {
791804 assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
792805
793- let fn_abi = FullyMonomorphizedLayoutCx ( fx. tcx )
794- . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ;
806+ let fn_abi = adjust_fn_abi_for_rust_abi_mistakes (
807+ fx. tcx ,
808+ FullyMonomorphizedLayoutCx ( fx. tcx )
809+ . fn_abi_of_instance ( drop_instance, ty:: List :: empty ( ) ) ,
810+ ) ;
795811
796812 let arg_value = drop_place. place_ref (
797813 fx,
0 commit comments