1
Fork 0

move has_repr to layout, handle repr(transparent) properly

This commit is contained in:
Erik Desjardins 2023-06-11 13:43:49 -04:00
parent 65d11b5c65
commit 00b3eca0df
6 changed files with 34 additions and 25 deletions

View file

@ -63,8 +63,8 @@ where
if t.is_like_msvc
&& arg.layout.is_adt()
&& let Some(requested_align) = arg.layout.repr_options().align
&& requested_align > align_4
&& arg.layout.has_repr_align
&& arg.layout.align.abi > align_4
{
// MSVC has special rules for overaligned arguments: https://reviews.llvm.org/D72114.
// Summarized here:
@ -72,11 +72,6 @@ where
// - For backwards compatibility, arguments with natural alignment > 4 are still passed
// on stack (via `byval`). For example, this includes `double`, `int64_t`,
// and structs containing them, provided they lack an explicit alignment attribute.
assert!(arg.layout.align.abi >= requested_align,
"abi alignment {:?} less than requested alignment {:?}",
arg.layout.align.abi,
requested_align
);
arg.make_indirect();
} else if arg.layout.is_aggregate() {
// We need to compute the alignment of the `byval` argument. The rules can be found in

View file

@ -55,7 +55,6 @@ pub trait TyAbiInterface<'a, C>: Sized {
fn is_never(this: TyAndLayout<'a, Self>) -> bool;
fn is_tuple(this: TyAndLayout<'a, Self>) -> bool;
fn is_unit(this: TyAndLayout<'a, Self>) -> bool;
fn repr_options(this: TyAndLayout<'a, Self>) -> ReprOptions;
}
impl<'a, Ty> TyAndLayout<'a, Ty> {
@ -126,13 +125,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Ty::is_unit(self)
}
pub fn repr_options<C>(self) -> ReprOptions
where
Ty: TyAbiInterface<'a, C>,
{
Ty::repr_options(self)
}
pub fn offset_of_subfield<C>(self, cx: &C, indices: impl Iterator<Item = usize>) -> Size
where
Ty: TyAbiInterface<'a, C>,