From 4bbae74458d42a475aa3ab728f67b576b6866a5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 17:38:17 +0200 Subject: [PATCH] Merge codegen_call_inner into codegen_terminator_call --- src/abi/mod.rs | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 5b81b48a09c..05ca51c452f 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -495,31 +495,6 @@ pub(crate) fn codegen_terminator_call<'tcx>( .collect::>() }; - codegen_call_inner( - fx, - span, - Some(func), - fn_ty, - args, - destination.map(|(place, _)| place), - ); - - if let Some((_, dest)) = destination { - let ret_block = fx.get_block(dest); - fx.bcx.ins().jump(ret_block, &[]); - } else { - trap_unreachable(fx, "[corruption] Diverging function returned"); - } -} - -fn codegen_call_inner<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - span: Span, - func: Option<&Operand<'tcx>>, - fn_ty: Ty<'tcx>, - args: Vec>, - ret_place: Option>, -) { // FIXME mark the current block as cold when calling a `#[cold]` function. let fn_sig = fx .tcx @@ -572,7 +547,7 @@ fn codegen_call_inner<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment(nop_inst, "indirect call"); } - let func = trans_operand(fx, func.expect("indirect call without func Operand")) + let func = trans_operand(fx, func) .load_scalar(fx); ( Some(func), @@ -584,6 +559,7 @@ fn codegen_call_inner<'tcx>( } }; + let ret_place = destination.map(|(place, _)| place); let (call_inst, call_args) = self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { let mut call_args: Vec = return_ptr @@ -641,6 +617,13 @@ fn codegen_call_inner<'tcx>( .collect::>(); fx.bcx.func.dfg.signatures[sig_ref].params = abi_params; } + + if let Some((_, dest)) = destination { + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); + } else { + trap_unreachable(fx, "[corruption] Diverging function returned"); + } } pub(crate) fn codegen_drop<'tcx>(