@@ -10,7 +10,6 @@ use rustc_target::abi::call::{Conv, FnAbi};
1010use rustc_target:: spec:: abi:: Abi ;
1111
1212use cranelift_codegen:: ir:: { AbiParam , SigRef } ;
13- use smallvec:: smallvec;
1413
1514use self :: pass_mode:: * ;
1615use crate :: prelude:: * ;
@@ -385,7 +384,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
385384 Indirect ( SigRef , Value ) ,
386385 }
387386
388- let ( func_ref, first_arg ) = match instance {
387+ let ( func_ref, first_arg_override ) = match instance {
389388 // Trait object call
390389 Some ( Instance { def : InstanceDef :: Virtual ( _, idx) , .. } ) => {
391390 if fx. clif_comments . enabled ( ) {
@@ -400,18 +399,13 @@ pub(crate) fn codegen_terminator_call<'tcx>(
400399 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. triple ( ) , & fn_abi) ;
401400 let sig = fx. bcx . import_signature ( sig) ;
402401
403- ( CallTarget :: Indirect ( sig, method) , smallvec ! [ ptr] )
402+ ( CallTarget :: Indirect ( sig, method) , Some ( ptr) )
404403 }
405404
406405 // Normal call
407406 Some ( instance) => {
408407 let func_ref = fx. get_function_ref ( instance) ;
409- (
410- CallTarget :: Direct ( func_ref) ,
411- args. get ( 0 )
412- . map ( |arg| adjust_arg_for_abi ( fx, * arg, & fn_abi. args [ 0 ] ) )
413- . unwrap_or ( smallvec ! [ ] ) ,
414- )
408+ ( CallTarget :: Direct ( func_ref) , None )
415409 }
416410
417411 // Indirect call
@@ -425,12 +419,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
425419 let sig = clif_sig_from_fn_abi ( fx. tcx , fx. triple ( ) , & fn_abi) ;
426420 let sig = fx. bcx . import_signature ( sig) ;
427421
428- (
429- CallTarget :: Indirect ( sig, func) ,
430- args. get ( 0 )
431- . map ( |arg| adjust_arg_for_abi ( fx, * arg, & fn_abi. args [ 0 ] ) )
432- . unwrap_or ( smallvec ! [ ] ) ,
433- )
422+ ( CallTarget :: Indirect ( sig, func) , None )
434423 }
435424 } ;
436425
@@ -443,11 +432,11 @@ pub(crate) fn codegen_terminator_call<'tcx>(
443432 let regular_args_count = args. len ( ) ;
444433 let mut call_args: Vec < Value > = return_ptr
445434 . into_iter ( )
446- . chain ( first_arg . into_iter ( ) )
435+ . chain ( first_arg_override . into_iter ( ) )
447436 . chain (
448437 args. into_iter ( )
449438 . enumerate ( )
450- . skip ( 1 )
439+ . skip ( if first_arg_override . is_some ( ) { 1 } else { 0 } )
451440 . map ( |( i, arg) | adjust_arg_for_abi ( fx, arg, & fn_abi. args [ i] ) . into_iter ( ) )
452441 . flatten ( ) ,
453442 )
0 commit comments