[clang] [CIR] Include union tail pad in getTypeSizeInBits (PR #198361)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 18 16:50:13 PDT 2026
================
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
+
+struct SSO {
+ char *p;
+ unsigned long len;
+ union {
+ char local[16];
+ unsigned long capacity;
+ };
+};
+
+// Inner union's tail padding must not bleed into the outer record.
+// CIR: !rec_anon{{.*}} = !cir.record<union "anon{{.*}}" padded {!cir.array<!s8i x 16>, !u64i, !cir.array<!u8i x 8>}>
----------------
adams381 wrote:
Agreed on the representation — tail pad should not be a third union member. Follow-up #198423 moves it to `padding = { … }` on `!cir.record<union …>` so `members` are only the co-located variants.
https://github.com/llvm/llvm-project/pull/198361
More information about the cfe-commits
mailing list