[IR] Optimize memory usage of Metadata on MSVC
authorReid Kleckner <rnk@google.com>
Wed, 13 Apr 2016 22:46:06 +0000 (22:46 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 13 Apr 2016 22:46:06 +0000 (22:46 +0000)
An unsigned 2 bit bitfield takes 4 bytes in MSVC. Instead of a bitfield,
just use an unsigned char. We can go back to a bitfield when someone
implements the TODO of exposing and reusing the remaining 6 bits.

llvm-svn: 266256

llvm/include/llvm/IR/Metadata.h

index 5d2bb1a..90651d0 100644 (file)
@@ -52,7 +52,7 @@ protected:
   enum StorageType { Uniqued, Distinct, Temporary };
 
   /// \brief Storage flag for non-uniqued, otherwise unowned, metadata.
-  unsigned Storage : 2;
+  unsigned char Storage;
   // TODO: expose remaining bits to subclasses.
 
   unsigned short SubclassData16;
@@ -93,6 +93,7 @@ public:
 protected:
   Metadata(unsigned ID, StorageType Storage)
       : SubclassID(ID), Storage(Storage), SubclassData16(0), SubclassData32(0) {
+    static_assert(sizeof(*this) == 8, "Metdata fields poorly packed");
   }
   ~Metadata() = default;