@@ -10,7 +10,6 @@ use rustc_target::abi::call::{Conv, FnAbi};
10
10
use rustc_target:: spec:: abi:: Abi ;
11
11
12
12
use cranelift_codegen:: ir:: { AbiParam , SigRef } ;
13
- use smallvec:: smallvec;
14
13
15
14
use self :: pass_mode:: * ;
16
15
use crate :: prelude:: * ;
@@ -385,7 +384,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
385
384
Indirect ( SigRef , Value ) ,
386
385
}
387
386
388
- let ( func_ref, first_arg ) = match instance {
387
+ let ( func_ref, first_arg_override ) = match instance {
389
388
// Trait object call
390
389
Some ( Instance { def : InstanceDef :: Virtual ( _, idx) , .. } ) => {
391
390
if fx. clif_comments . enabled ( ) {
@@ -400,18 +399,13 @@ pub(crate) fn codegen_terminator_call<'tcx>(
400
399
let sig = clif_sig_from_fn_abi ( fx. tcx , fx. triple ( ) , & fn_abi) ;
401
400
let sig = fx. bcx . import_signature ( sig) ;
402
401
403
- ( CallTarget :: Indirect ( sig, method) , smallvec ! [ ptr] )
402
+ ( CallTarget :: Indirect ( sig, method) , Some ( ptr) )
404
403
}
405
404
406
405
// Normal call
407
406
Some ( instance) => {
408
407
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 )
415
409
}
416
410
417
411
// Indirect call
@@ -425,12 +419,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
425
419
let sig = clif_sig_from_fn_abi ( fx. tcx , fx. triple ( ) , & fn_abi) ;
426
420
let sig = fx. bcx . import_signature ( sig) ;
427
421
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 )
434
423
}
435
424
} ;
436
425
@@ -443,11 +432,11 @@ pub(crate) fn codegen_terminator_call<'tcx>(
443
432
let regular_args_count = args. len ( ) ;
444
433
let mut call_args: Vec < Value > = return_ptr
445
434
. into_iter ( )
446
- . chain ( first_arg . into_iter ( ) )
435
+ . chain ( first_arg_override . into_iter ( ) )
447
436
. chain (
448
437
args. into_iter ( )
449
438
. enumerate ( )
450
- . skip ( 1 )
439
+ . skip ( if first_arg_override . is_some ( ) { 1 } else { 0 } )
451
440
. map ( |( i, arg) | adjust_arg_for_abi ( fx, arg, & fn_abi. args [ i] ) . into_iter ( ) )
452
441
. flatten ( ) ,
453
442
)
0 commit comments