[PATCH] D32001: [APInt] Reorder fields to avoid a hole in the middle of the class

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 22:12:00 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL300171: [APInt] Reorder fields to avoid a hole in the middle of the class (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D32001?vs=95077&id=95080#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32001

Files:
  llvm/trunk/include/llvm/ADT/APInt.h
  llvm/trunk/lib/Support/APInt.cpp


Index: llvm/trunk/lib/Support/APInt.cpp
===================================================================
--- llvm/trunk/lib/Support/APInt.cpp
+++ llvm/trunk/lib/Support/APInt.cpp
@@ -120,7 +120,7 @@
 }
 
 APInt::APInt(unsigned numbits, StringRef Str, uint8_t radix)
-  : BitWidth(numbits), VAL(0) {
+  : VAL(0), BitWidth(numbits) {
   assert(BitWidth && "Bitwidth too small");
   fromString(numbits, Str, radix);
 }
Index: llvm/trunk/include/llvm/ADT/APInt.h
===================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h
+++ llvm/trunk/include/llvm/ADT/APInt.h
@@ -79,22 +79,22 @@
   };
 
 private:
-  unsigned BitWidth; ///< The number of bits in this APInt.
-
   /// This union is used to store the integer value. When the
   /// integer bit-width <= 64, it uses VAL, otherwise it uses pVal.
   union {
     uint64_t VAL;   ///< Used to store the <= 64 bits integer value.
     uint64_t *pVal; ///< Used to store the >64 bits integer value.
   };
 
+  unsigned BitWidth; ///< The number of bits in this APInt.
+
   friend struct DenseMapAPIntKeyInfo;
 
   /// \brief Fast internal constructor
   ///
   /// This constructor is used only internally for speed of construction of
   /// temporaries. It is unsafe for general use so it is not public.
-  APInt(uint64_t *val, unsigned bits) : BitWidth(bits), pVal(val) {}
+  APInt(uint64_t *val, unsigned bits) : pVal(val), BitWidth(bits) {}
 
   /// \brief Determine if this APInt just has one word to store value.
   ///
@@ -290,7 +290,7 @@
   }
 
   /// \brief Move Constructor.
-  APInt(APInt &&that) : BitWidth(that.BitWidth), VAL(that.VAL) {
+  APInt(APInt &&that) : VAL(that.VAL), BitWidth(that.BitWidth) {
     that.BitWidth = 0;
   }
 
@@ -305,7 +305,7 @@
   ///
   /// This is useful for object deserialization (pair this with the static
   ///  method Read).
-  explicit APInt() : BitWidth(1), VAL(0) {}
+  explicit APInt() : VAL(0), BitWidth(1) {}
 
   /// \brief Returns whether this instance allocated memory.
   bool needsCleanup() const { return !isSingleWord(); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32001.95080.patch
Type: text/x-patch
Size: 2077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/cb824487/attachment-0001.bin>


More information about the llvm-commits mailing list