================
@@ -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
----------------
erichkeane wrote:
Rather than 2 long comments, can we just do a bit of a 'top post' here
describing the functionality here?
This isn't complex enough to require 7 lines of comment. In reality, this
whole function isn't much more than 1-liner...
https://github.com/llvm/llvm-project/pull/213591
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits