Minor cleanups to fn_abi_new_uncached

This commit is contained in:
bjorn3 2026-01-07 16:26:52 +00:00
parent 84c84421cc
commit aec8b69878
2 changed files with 8 additions and 15 deletions

View file

@ -381,15 +381,14 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
pub fn new(
cx: &impl HasDataLayout,
layout: TyAndLayout<'a, Ty>,
scalar_attrs: impl Fn(&TyAndLayout<'a, Ty>, Scalar, Size) -> ArgAttributes,
scalar_attrs: impl Fn(Scalar, Size) -> ArgAttributes,
) -> Self {
let mode = match layout.backend_repr {
BackendRepr::Scalar(scalar) => {
PassMode::Direct(scalar_attrs(&layout, scalar, Size::ZERO))
}
_ if layout.is_zst() => PassMode::Ignore,
BackendRepr::Scalar(scalar) => PassMode::Direct(scalar_attrs(scalar, Size::ZERO)),
BackendRepr::ScalarPair(a, b) => PassMode::Pair(
scalar_attrs(&layout, a, Size::ZERO),
scalar_attrs(&layout, b, a.size(cx).align_to(b.align(cx).abi)),
scalar_attrs(a, Size::ZERO),
scalar_attrs(b, a.size(cx).align_to(b.align(cx).abi)),
),
BackendRepr::SimdVector { .. } => PassMode::Direct(ArgAttributes::new()),
BackendRepr::Memory { .. } => Self::indirect_pass_mode(&layout),

View file

@ -549,15 +549,9 @@ fn fn_abi_new_uncached<'tcx>(
layout
};
let mut arg = ArgAbi::new(cx, layout, |layout, scalar, offset| {
arg_attrs_for_rust_scalar(*cx, scalar, *layout, offset, is_return, drop_target_pointee)
});
if arg.layout.is_zst() {
arg.mode = PassMode::Ignore;
}
Ok(arg)
Ok(ArgAbi::new(cx, layout, |scalar, offset| {
arg_attrs_for_rust_scalar(*cx, scalar, layout, offset, is_return, drop_target_pointee)
}))
};
let mut fn_abi = FnAbi {