[llvm] [VPlan] Use pragma pack(1) for VPIRFlags on AIX. (PR #184687)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 5 10:51:00 PST 2026


https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/184687

>From c28b3d1faeafadbad1e36c136fb472d61524099d Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Wed, 4 Mar 2026 21:00:49 +0000
Subject: [PATCH 1/2] [VPlan] Use pragma pack(1) for VPIRFlags on AIX.

Except for GCC; by default, AIX compilers store bit-fields in 4-byte
words. This means that VPIRFlags is larger than expected.

Use pack(1) to ensure smaller packing, matching other platforms.

This matches what we already do in other places for AIX, e.g. in
llvm/include/llvm/CodeGen/SelectionDAGNodes.h (added in
844a02e509a4cc03f76ef5dd1c358c57ee164b71)
---
 llvm/lib/Transforms/Vectorize/VPlan.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 41eef2a368343..d2ea1b362ccba 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -668,6 +668,16 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue {
 };
 
 /// Class to record and manage LLVM IR flags.
+#if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
+// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
+// and give the `pack` pragma push semantics.
+#define BEGIN_ONE_BYTE_PACK() _Pragma("pack(1)")
+#define END_ONE_BYTE_PACK() _Pragma("pack(pop)")
+#else
+#define BEGIN_ONE_BYTE_PACK()
+#define END_ONE_BYTE_PACK()
+#endif
+BEGIN_ONE_BYTE_PACK()
 class VPIRFlags {
   enum class OperationType : unsigned char {
     Cmp,
@@ -1070,6 +1080,9 @@ class VPIRFlags {
   void printFlags(raw_ostream &O) const;
 #endif
 };
+END_ONE_BYTE_PACK()
+#undef BEGIN_ONE_BYTE_PACK
+#undef END_ONE_BYTE_PACK
 
 static_assert(sizeof(VPIRFlags) <= 3, "VPIRFlags should not grow");
 

>From 290009ba5c44273773587f43faf5312dd51c05d4 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 5 Mar 2026 18:50:42 +0000
Subject: [PATCH 2/2] !fixup use LLVM_PACKED

---
 llvm/lib/Transforms/Vectorize/VPlan.h | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 2b67d7e03129d..36728d101196f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -668,16 +668,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue {
 };
 
 /// Class to record and manage LLVM IR flags.
-#if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
-// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
-// and give the `pack` pragma push semantics.
-#define BEGIN_ONE_BYTE_PACK() _Pragma("pack(1)")
-#define END_ONE_BYTE_PACK() _Pragma("pack(pop)")
-#else
-#define BEGIN_ONE_BYTE_PACK()
-#define END_ONE_BYTE_PACK()
-#endif
-BEGIN_ONE_BYTE_PACK()
+LLVM_PACKED_START
 class VPIRFlags {
   enum class OperationType : unsigned char {
     Cmp,
@@ -1080,9 +1071,7 @@ class VPIRFlags {
   void printFlags(raw_ostream &O) const;
 #endif
 };
-END_ONE_BYTE_PACK()
-#undef BEGIN_ONE_BYTE_PACK
-#undef END_ONE_BYTE_PACK
+LLVM_PACKED_END
 
 static_assert(sizeof(VPIRFlags) <= 3, "VPIRFlags should not grow");
 



More information about the llvm-commits mailing list