From 55e47a634f841bf4722956f6498a0a1ea6c70993 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 13 Apr 2016 22:46:06 +0000 Subject: [PATCH] [IR] Optimize memory usage of Metadata on MSVC 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266256 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Metadata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index 5d2bb1ae19b..90651d00ef8 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -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;