================ @@ -225,17 +235,108 @@ void RecordType::complete(ArrayRef<Type> members, bool packed, bool padded) { //===----------------------------------------------------------------------===// llvm::TypeSize -RecordType::getTypeSizeInBits(const ::mlir::DataLayout &dataLayout, - ::mlir::DataLayoutEntryListRef params) const { - assert(!cir::MissingFeatures::recordTypeLayoutInfo()); - return llvm::TypeSize::getFixed(8); +RecordType::getTypeSizeInBits(const mlir::DataLayout &dataLayout, + mlir::DataLayoutEntryListRef params) const { + if (!layoutInfo) + computeSizeAndAlignment(dataLayout); + return llvm::TypeSize::getFixed( + mlir::cast<cir::RecordLayoutAttr>(layoutInfo).getSize() * 8); } uint64_t RecordType::getABIAlignment(const ::mlir::DataLayout &dataLayout, ::mlir::DataLayoutEntryListRef params) const { - assert(!cir::MissingFeatures::recordTypeLayoutInfo()); - return 4; + if (!layoutInfo) + computeSizeAndAlignment(dataLayout); + return mlir::cast<cir::RecordLayoutAttr>(layoutInfo).getAlignment(); +} + +void RecordType::computeSizeAndAlignment( + const mlir::DataLayout &dataLayout) const { + assert(isComplete() && "Cannot get layout of incomplete records"); + // Do not recompute. + if (layoutInfo) ---------------- bcardosolopes wrote:
> verified that even with a simple test case > (clang/test/CIR/CodeGen/struct.cpp) we recompute the layout multiple times > for the same type. This just isn't working the way it was intended. Thanks for double checking https://github.com/llvm/llvm-project/pull/136036 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits