pub(super) fn codegen_with_call_return_arg<'tcx>(
    fx: &mut FunctionCx<'_, '_, 'tcx>,
    ret_arg_abi: &ArgAbi<'tcx, Ty<'tcx>>,
    ret_place: CPlace<'tcx>,
    f: impl FnOnce(&mut FunctionCx<'_, '_, 'tcx>, Option<Value>) -> SmallVec<[Value; 2]>,
) {
    let (ret_temp_place, return_ptr) = match ret_arg_abi.mode {
        PassMode::Ignore => (None, None),
        PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
            if let Some(ret_ptr) = ret_place.try_to_ptr() {
                // This is an optimization to prevent unnecessary copies of the return value when
                // the return place is already a memory place as opposed to a register.
                // This match arm can be safely removed.
                (None, Some(ret_ptr.get_addr(fx)))
            } else {
                let place = CPlace::new_stack_slot(fx, ret_arg_abi.layout);
                (Some(place), Some(place.to_ptr().get_addr(fx)))
            }
        }
        PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
            unreachable!("unsized return value")
        }
        PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast { .. } => (None, None),
    };

    let results = f(fx, return_ptr);

    match ret_arg_abi.mode {
        PassMode::Ignore => {}
        PassMode::Direct(_) => {
            let ret_val = results[0];
            ret_place.write_cvalue(fx, CValue::by_val(ret_val, ret_arg_abi.layout));
        }
        PassMode::Pair(_, _) => {
            let ret_val_a = results[0];
            let ret_val_b = results[1];
            ret_place
                .write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_arg_abi.layout));
        }
        PassMode::Cast { ref cast, .. } => {
            let result =
                super::pass_mode::from_casted_value(fx, &results, ret_place.layout(), cast);
            ret_place.write_cvalue(fx, result);
        }
        PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: _ } => {
            if let Some(ret_temp_place) = ret_temp_place {
                // If ret_temp_place is None, it is not necessary to copy the return value.
                let ret_temp_value = ret_temp_place.to_cvalue(fx);
                ret_place.write_cvalue(fx, ret_temp_value);
            }
        }
        PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
            unreachable!("unsized return value")
        }
    }
}
Invokes the closure with if necessary a value representing the return pointer. When the closure
returns the call return value(s) if any are written to the correct place.
src/abi/returning.rs