[clang] [CIR] Upstream support for record packing and padding (PR #136036)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 16:46:23 PDT 2025


================
@@ -502,6 +502,15 @@ def CIR_RecordType : CIR_Type<"Record", "record",
 
     void complete(llvm::ArrayRef<mlir::Type> members, bool packed,
                   bool isPadded);
+
+  // Utilities for lazily computing and cacheing data layout info.
+  // FIXME: currently opaque because there's a cycle if CIRTypes.types include
+  // from CIRAttrs.h. The implementation operates in terms of RecordLayoutAttr
+  // instead.
+  private:
+    mutable mlir::Attribute layoutInfo;
----------------
andykaylor wrote:

I've just put up a PR in the incubator (https://github.com/llvm/clangir/pull/1569) to calculate the required information (and only the required information) on demand. I don't know if we want to make this change there or wait for a proper caching mechanism instead, but I thought it would be useful to have as a preview of a complete implementation following the path we've discussed here. All regression tests passed in my sandbox with that change.

https://github.com/llvm/llvm-project/pull/136036


More information about the cfe-commits mailing list