[flang-commits] [flang] [flang] Fix `getTypeSizeAndAlignment` for packed/tail-padded `RecordType` and `TRANSFER` gate (PR #220377)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Thu Sep 3 06:05:04 PDT 2026


================
@@ -102,4 +102,44 @@ func.func @small_temp_in_acc_parallel() {
   return
 }
 
+// Tail-padded record array: !fir.array<3x!fir.type<tpad{a:i32,b:i8}>>
+// Each element is 8 bytes (5 typed + 3 tail padding), total = 24 bytes.
+// getTypeSizeAndAlignment must return 8 per element so the pass computes the
+// correct total of 24 bytes.  With the default 64-byte threshold this
+// 24-byte temporary array is small and must be promoted to stack.
+// CHECK-LABEL: func.func @tail_padded_record_placement
+// CHECK: fir.alloca !fir.array<3x!fir.type<tpad{a:i32,b:i8}>>
+// CHECK-NOT: fir.allocmem
+func.func @tail_padded_record_placement() {
+  %0 = fir.allocmem !fir.array<3x!fir.type<tpad{a:i32,b:i8}>>
----------------
DanielCChen wrote:

Right! Fixed.

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


More information about the flang-commits mailing list