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

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Tue Sep 15 07:06:24 PDT 2026


================
@@ -1653,7 +1654,8 @@ fir::getTypeSizeAndAlignment(mlir::Location loc, mlir::Type ty,
     // Dynamic / unknown shapes have no compile-time byte size.
     if (seqTy.hasDynamicExtents() || seqTy.hasUnknownShape())
       return std::nullopt;
-    auto result = getTypeSizeAndAlignment(loc, seqTy.getEleTy(), dl, kindMap);
+    auto result = getTypeSizeAndAlignmentImpl(loc, seqTy.getEleTy(), dl,
+                                              kindMap, storeSizeOnly);
----------------
DanielCChen wrote:

Good point on the intent. `storeSizeOnly` only suppresses the final `llvm::alignTo(rawSize, recordAlign)` in the `RecordType` path. The `SequenceType` stride calculation immediately re-applies `llvm::alignTo(eleSize, eleAlign)`, so the suppressed rounding is always re-introduced — the per-element allocation size used as stride is identical whether `storeSizeOnly` is true or false. For example, `{i32, i8}` (raw=5, align=4): `storeSizeOnly=true` gives `eleSize=5` → stride `alignTo(5,4)=8`; `storeSizeOnly=false` gives `eleSize=8` → stride `alignTo(8,4)=8`.

Also, `getTypeStoreSizeAndAlignment` is only called with a top-level `RecordType` or trivial scalar (guarded at the `TRANSFER` call site), so `SequenceType` is only reached via recursion through an array-typed record field.

I've added a comment to the `SequenceType` branch to make this clear.

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


More information about the flang-commits mailing list