================
@@ -918,6 +931,17 @@ UnionType::getABIAlignment(const ::mlir::DataLayout
&dataLayout,
return dataLayout.getTypeABIAlignment(storage);
}
+uint64_t
+UnionType::getRequiredAlignment(const ::mlir::DataLayout &dataLayout,
----------------
adams381 wrote:
The storage member is chosen by ABI alignment, so once the two differ it isn't
necessarily the member with the largest required alignment. For `union {
_BitInt(129) b; int i; }` on x86-64, the `_BitInt` has ABI alignment 1, so
`int` is chosen as storage and this returns 4 while the union's C alignment is
8. I confirmed that with a unit test using the x86-64 layout from
`IntTypeABIAlignTest`, and a struct with the same members correctly returns 8.
Taking the max of `getTypeRequiredAlignment` over `getMembers()`, as
`StructType::getRequiredAlignment` does, would fix it. I didn't find a current
caller where this produces wrong code, since the low value only reaches memcpy
fallbacks, but it seems worth fixing before something relies on it.
https://github.com/llvm/llvm-project/pull/243165
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits