[llvm] 967eeb1 - [AIX] Pack BasicBlockBits

David Tenty via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 11:28:54 PST 2020


Author: David Tenty
Date: 2020-02-20T14:28:48-05:00
New Revision: 967eeb109bedc4ae606fdf6ad6eca58ffbac6739

URL: https://github.com/llvm/llvm-project/commit/967eeb109bedc4ae606fdf6ad6eca58ffbac6739
DIFF: https://github.com/llvm/llvm-project/commit/967eeb109bedc4ae606fdf6ad6eca58ffbac6739.diff

LOG: [AIX] Pack BasicBlockBits

Summary:
D51664 introduces a new structure BasicBlockBits which it expects to be
packed a certain way. This change is very similar to D60164, and we apply the
same fix:

"On AIX, the canonical layout of bit-fields would cause
these ... to span four bytes. Applying the pack pragma for compilers that
employ the AIX canonical layout allows these ... to fit within the expected
two bytes. In the future, the pragma would also likely need to be applied when
building with Clang on AIX."

Reviewers: jasonliu, hubert.reinterpretcast, sfertile, xingxue

Reviewed By: sfertile

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74911

Added: 
    

Modified: 
    llvm/include/llvm/IR/BasicBlock.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index f04fbd23e964..4a3c649c7af2 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -461,11 +461,26 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
   void validateInstrOrdering() const;
 
 private:
+#if defined(_AIX) && (!defined(__GNUC__) || defined(__ibmxl__))
+// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
+// and give the `pack` pragma push semantics.
+#define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
+#define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
+#else
+#define BEGIN_TWO_BYTE_PACK()
+#define END_TWO_BYTE_PACK()
+#endif
+
+  BEGIN_TWO_BYTE_PACK()
   /// Bitfield to help interpret the bits in Value::SubclassData.
   struct BasicBlockBits {
     unsigned short BlockAddressRefCount : 15;
     unsigned short InstrOrderValid : 1;
   };
+  END_TWO_BYTE_PACK()
+
+#undef BEGIN_TWO_BYTE_PACK
+#undef END_TWO_BYTE_PACK
 
   /// Safely reinterpret the subclass data bits to a more useful form.
   BasicBlockBits getBasicBlockBits() const {


        


More information about the llvm-commits mailing list