@@ -24,6 +24,7 @@ use rustc_span::source_map::Spanned;
24
24
use rustc_target:: callconv:: { FnAbi , PassMode } ;
25
25
use smallvec:: { SmallVec , smallvec} ;
26
26
27
+ pub ( crate ) use self :: pass_mode:: adjust_fn_abi_for_rust_abi_mistakes;
27
28
use self :: pass_mode:: * ;
28
29
pub ( crate ) use self :: returning:: codegen_return;
29
30
use crate :: base:: codegen_unwind_terminate;
@@ -85,7 +86,10 @@ pub(crate) fn get_function_sig<'tcx>(
85
86
clif_sig_from_fn_abi (
86
87
tcx,
87
88
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
+ ) ,
89
93
)
90
94
}
91
95
@@ -461,11 +465,14 @@ pub(crate) fn codegen_terminator_call<'tcx>(
461
465
let extra_args = fx. tcx . mk_type_list_from_iter (
462
466
extra_args. iter ( ) . map ( |op_arg| fx. monomorphize ( op_arg. node . ty ( fx. mir , fx. tcx ) ) ) ,
463
467
) ;
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
+ ) ;
469
476
470
477
let is_cold = if fn_sig. abi ( ) == ExternAbi :: RustCold {
471
478
true
@@ -736,8 +743,11 @@ pub(crate) fn codegen_drop<'tcx>(
736
743
def : ty:: InstanceKind :: Virtual ( drop_instance. def_id ( ) , 0 ) ,
737
744
args : drop_instance. args ,
738
745
} ;
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
+ ) ;
741
751
742
752
let sig = clif_sig_from_fn_abi ( fx. tcx , fx. target_config . default_call_conv , & fn_abi) ;
743
753
let sig = fx. bcx . import_signature ( sig) ;
@@ -753,8 +763,11 @@ pub(crate) fn codegen_drop<'tcx>(
753
763
_ => {
754
764
assert ! ( !matches!( drop_instance. def, InstanceKind :: Virtual ( _, _) ) ) ;
755
765
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
+ ) ;
758
771
759
772
let arg_value = drop_place. place_ref (
760
773
fx,
0 commit comments