[flang-commits] [flang] [flang] Fix RecordType sizes, TRANSFER lowering, and BIND(C) ABI on SystemZ/PPC64le (PR #220377)

via flang-commits flang-commits at lists.llvm.org
Thu Sep 10 12:49:44 PDT 2026


================
@@ -1661,15 +1663,40 @@ fir::getTypeSizeAndAlignment(mlir::Location loc, mlir::Type ty,
   if (auto recTy = mlir::dyn_cast<fir::RecordType>(ty)) {
     std::uint64_t size = 0;
     unsigned short align = 1;
+    if (recTy.isPacked()) {
+      // LLVM packed structs (<{ ... }>) place fields back-to-back with no
+      // inter-field alignment padding and no tail padding.  Each component
+      // still occupies its allocation size (llvm::alignTo(storeSize, ABI
+      // alignment)), because LLVM's packed StructLayout advances by
+      // getTypeAllocSize, not getTypeStoreSize.  For example, x86 f80 has
----------------
MattPD wrote:

Thanks for simplifying the description. Could the last sentence under `Bytewise copy` be dropped?

The earlier eight-byte copy example had an eight-byte result too. With an eight-byte `{i32,i8}` source and an `INTEGER(4)` mold, the result has four bytes. [`TransferImpl` bounds the copy by the result capacity](https://github.com/llvm/llvm-project/blob/00e5d86e3f845f92e94d74674bae62c6acf54825/flang-rt/lib/runtime/misc-intrinsic.cpp#L22-L46), so this case copies four bytes, not the full source allocation. The byte-copy rationale does not need that runtime-width sentence.

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


More information about the flang-commits mailing list