[llvm] [VPlan] Use pragma pack(1) for VPIRFlags on AIX. (PR #184687)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 13:06:04 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: Florian Hahn (fhahn)
<details>
<summary>Changes</summary>
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)
---
Full diff: https://github.com/llvm/llvm-project/pull/184687.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+13)
``````````diff
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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/184687
More information about the llvm-commits
mailing list