================
@@ -727,15 +727,16 @@ StructType::getABIAlignment(const ::mlir::DataLayout
&dataLayout,
llvm::TypeSize
UnionType::getTypeSizeInBits(const mlir::DataLayout &dataLayout,
mlir::DataLayoutEntryListRef params) const {
- mlir::Type storage = getUnionStorageType(dataLayout);
- if (!storage)
- return llvm::TypeSize::getFixed(0);
+ // A union whose member list came out empty has no storage type, so whatever
+ // size it has lives entirely in the padding field below. Sum both.
+ llvm::TypeSize size = llvm::TypeSize::getFixed(0);
+ if (mlir::Type storage = getUnionStorageType(dataLayout))
+ size += dataLayout.getTypeSizeInBits(storage);
// The padding field holds enough bytes to bring the total up to the AST
----------------
adams381 wrote:
I've simplified the comments to a single top comment that is now a three-liner.
The effect is subtle enough I don't want it to get lost again.
I agree about `getTypeSizeInBits`. I'll try to keep that in mind.
https://github.com/llvm/llvm-project/pull/213591
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits