Skip to content

Commit 4bbae74

Browse files
committed
Merge codegen_call_inner into codegen_terminator_call
1 parent 04af24d commit 4bbae74

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/abi/mod.rs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -495,31 +495,6 @@ pub(crate) fn codegen_terminator_call<'tcx>(
495495
.collect::<Vec<_>>()
496496
};
497497

498-
codegen_call_inner(
499-
fx,
500-
span,
501-
Some(func),
502-
fn_ty,
503-
args,
504-
destination.map(|(place, _)| place),
505-
);
506-
507-
if let Some((_, dest)) = destination {
508-
let ret_block = fx.get_block(dest);
509-
fx.bcx.ins().jump(ret_block, &[]);
510-
} else {
511-
trap_unreachable(fx, "[corruption] Diverging function returned");
512-
}
513-
}
514-
515-
fn codegen_call_inner<'tcx>(
516-
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
517-
span: Span,
518-
func: Option<&Operand<'tcx>>,
519-
fn_ty: Ty<'tcx>,
520-
args: Vec<CValue<'tcx>>,
521-
ret_place: Option<CPlace<'tcx>>,
522-
) {
523498
// FIXME mark the current block as cold when calling a `#[cold]` function.
524499
let fn_sig = fx
525500
.tcx
@@ -572,7 +547,7 @@ fn codegen_call_inner<'tcx>(
572547
let nop_inst = fx.bcx.ins().nop();
573548
fx.add_comment(nop_inst, "indirect call");
574549
}
575-
let func = trans_operand(fx, func.expect("indirect call without func Operand"))
550+
let func = trans_operand(fx, func)
576551
.load_scalar(fx);
577552
(
578553
Some(func),
@@ -584,6 +559,7 @@ fn codegen_call_inner<'tcx>(
584559
}
585560
};
586561

562+
let ret_place = destination.map(|(place, _)| place);
587563
let (call_inst, call_args) =
588564
self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| {
589565
let mut call_args: Vec<Value> = return_ptr
@@ -641,6 +617,13 @@ fn codegen_call_inner<'tcx>(
641617
.collect::<Vec<AbiParam>>();
642618
fx.bcx.func.dfg.signatures[sig_ref].params = abi_params;
643619
}
620+
621+
if let Some((_, dest)) = destination {
622+
let ret_block = fx.get_block(dest);
623+
fx.bcx.ins().jump(ret_block, &[]);
624+
} else {
625+
trap_unreachable(fx, "[corruption] Diverging function returned");
626+
}
644627
}
645628

646629
pub(crate) fn codegen_drop<'tcx>(

0 commit comments

Comments
 (0)