@@ -424,66 +424,65 @@ pub(crate) fn codegen_terminator_call<'tcx>(
424424 } ;
425425
426426 let ret_place = destination. map ( |( place, _) | place) ;
427- let ( call_inst, call_args) = self :: returning:: codegen_with_call_return_arg (
428- fx,
429- & fn_abi. ret ,
430- ret_place,
431- |fx, return_ptr| {
432- let regular_args_count = args. len ( ) ;
433- let mut call_args: Vec < Value > = return_ptr
434- . into_iter ( )
435- . chain ( first_arg_override. into_iter ( ) )
436- . chain (
437- args. into_iter ( )
438- . enumerate ( )
439- . skip ( if first_arg_override. is_some ( ) { 1 } else { 0 } )
440- . map ( |( i, arg) | adjust_arg_for_abi ( fx, arg, & fn_abi. args [ i] ) . into_iter ( ) )
441- . flatten ( ) ,
442- )
443- . collect :: < Vec < _ > > ( ) ;
444-
445- if instance. map ( |inst| inst. def . requires_caller_location ( fx. tcx ) ) . unwrap_or ( false ) {
446- // Pass the caller location for `#[track_caller]`.
447- let caller_location = fx. get_caller_location ( span) ;
448- call_args. extend (
449- adjust_arg_for_abi ( fx, caller_location, & fn_abi. args [ regular_args_count] )
450- . into_iter ( ) ,
451- ) ;
452- assert_eq ! ( fn_abi. args. len( ) , regular_args_count + 1 ) ;
453- } else {
454- assert_eq ! ( fn_abi. args. len( ) , regular_args_count) ;
455- }
456-
457- let call_inst = match func_ref {
458- CallTarget :: Direct ( func_ref) => fx. bcx . ins ( ) . call ( func_ref, & call_args) ,
459- CallTarget :: Indirect ( sig, func_ptr) => {
460- fx. bcx . ins ( ) . call_indirect ( sig, func_ptr, & call_args)
461- }
462- } ;
427+ self :: returning:: codegen_with_call_return_arg ( fx, & fn_abi. ret , ret_place, |fx, return_ptr| {
428+ let regular_args_count = args. len ( ) ;
429+ let mut call_args: Vec < Value > = return_ptr
430+ . into_iter ( )
431+ . chain ( first_arg_override. into_iter ( ) )
432+ . chain (
433+ args. into_iter ( )
434+ . enumerate ( )
435+ . skip ( if first_arg_override. is_some ( ) { 1 } else { 0 } )
436+ . map ( |( i, arg) | adjust_arg_for_abi ( fx, arg, & fn_abi. args [ i] ) . into_iter ( ) )
437+ . flatten ( ) ,
438+ )
439+ . collect :: < Vec < _ > > ( ) ;
440+
441+ if instance. map ( |inst| inst. def . requires_caller_location ( fx. tcx ) ) . unwrap_or ( false ) {
442+ // Pass the caller location for `#[track_caller]`.
443+ let caller_location = fx. get_caller_location ( span) ;
444+ call_args. extend (
445+ adjust_arg_for_abi ( fx, caller_location, & fn_abi. args [ regular_args_count] )
446+ . into_iter ( ) ,
447+ ) ;
448+ assert_eq ! ( fn_abi. args. len( ) , regular_args_count + 1 ) ;
449+ } else {
450+ assert_eq ! ( fn_abi. args. len( ) , regular_args_count) ;
451+ }
463452
464- ( call_inst, call_args)
465- } ,
466- ) ;
453+ let call_inst = match func_ref {
454+ CallTarget :: Direct ( func_ref) => fx. bcx . ins ( ) . call ( func_ref, & call_args) ,
455+ CallTarget :: Indirect ( sig, func_ptr) => {
456+ fx. bcx . ins ( ) . call_indirect ( sig, func_ptr, & call_args)
457+ }
458+ } ;
467459
468- // FIXME find a cleaner way to support varargs
469- if fn_sig. c_variadic {
470- if !matches ! ( fn_sig. abi, Abi :: C { .. } ) {
471- fx. tcx . sess . span_fatal ( span, & format ! ( "Variadic call for non-C abi {:?}" , fn_sig. abi) ) ;
460+ // FIXME find a cleaner way to support varargs
461+ if fn_sig. c_variadic {
462+ if !matches ! ( fn_sig. abi, Abi :: C { .. } ) {
463+ fx. tcx
464+ . sess
465+ . span_fatal ( span, & format ! ( "Variadic call for non-C abi {:?}" , fn_sig. abi) ) ;
466+ }
467+ let sig_ref = fx. bcx . func . dfg . call_signature ( call_inst) . unwrap ( ) ;
468+ let abi_params = call_args
469+ . into_iter ( )
470+ . map ( |arg| {
471+ let ty = fx. bcx . func . dfg . value_type ( arg) ;
472+ if !ty. is_int ( ) {
473+ // FIXME set %al to upperbound on float args once floats are supported
474+ fx. tcx
475+ . sess
476+ . span_fatal ( span, & format ! ( "Non int ty {:?} for variadic call" , ty) ) ;
477+ }
478+ AbiParam :: new ( ty)
479+ } )
480+ . collect :: < Vec < AbiParam > > ( ) ;
481+ fx. bcx . func . dfg . signatures [ sig_ref] . params = abi_params;
472482 }
473- let sig_ref = fx. bcx . func . dfg . call_signature ( call_inst) . unwrap ( ) ;
474- let abi_params = call_args
475- . into_iter ( )
476- . map ( |arg| {
477- let ty = fx. bcx . func . dfg . value_type ( arg) ;
478- if !ty. is_int ( ) {
479- // FIXME set %al to upperbound on float args once floats are supported
480- fx. tcx . sess . span_fatal ( span, & format ! ( "Non int ty {:?} for variadic call" , ty) ) ;
481- }
482- AbiParam :: new ( ty)
483- } )
484- . collect :: < Vec < AbiParam > > ( ) ;
485- fx. bcx . func . dfg . signatures [ sig_ref] . params = abi_params;
486- }
483+
484+ call_inst
485+ } ) ;
487486
488487 if let Some ( ( _, dest) ) = destination {
489488 let ret_block = fx. get_block ( dest) ;
0 commit comments