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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 13:05:16 PST 2026


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

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)

>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] [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");
 



More information about the llvm-commits mailing list