[VPlan] Use pragma pack(1) for VPIRFlags on AIX.#184687
Conversation
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 844a02e)
|
@llvm/pr-subscribers-vectorizers Author: Florian Hahn (fhahn) ChangesExcept 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 844a02e) Full diff: https://github.com/llvm/llvm-project/pull/184687.diff 1 Files Affected:
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");
|
|
@llvm/pr-subscribers-llvm-transforms Author: Florian Hahn (fhahn) ChangesExcept 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 844a02e) Full diff: https://github.com/llvm/llvm-project/pull/184687.diff 1 Files Affected:
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");
|
|
@kkwli @hubert-reinterpretcast I think this should fix the build failure mentioned in #181571 for AIX, but I am not able to verify locally. Would be great if you could help |
|
I added this fix to my branch to test on AIX but ended up with different errors: On commit: |
|
@midhuncodes7 is this with a clean build? So far looks like this commit is fine on the build bots. |
|
The changes introduced in this PR: #170053 along with the fix provided in the current PR was built clean and results with the posted error. |
kkwli
left a comment
There was a problem hiding this comment.
LG. I can successfully build the patch on AIX without encountering the previously described error.
artagnon
left a comment
There was a problem hiding this comment.
If this fixes the issue, well and good. LGTM, thanks!
Some compilers (e.g. on AIX) do not pack by default. Use LLVM_PACKED to ensure the VPIRFlags struct is packed as expected on all platforms. This matches what we already do in other places for AIX, e.g. in llvm/include/llvm/CodeGen/SelectionDAGNodes.h (added in 844a02e), although it uses the more general LLVM_PACKED unconditionally PR: llvm/llvm-project#184687
Some compilers (e.g. on AIX) do not pack by default. Use LLVM_PACKED to ensure the VPIRFlags struct is packed as expected on all platforms.
This matches what we already do in other places for AIX, e.g. in llvm/include/llvm/CodeGen/SelectionDAGNodes.h (added in 844a02e), although it uses the more general LLVM_PACKED unconditionally