[llvm] r266256 - [IR] Optimize memory usage of Metadata on MSVC
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 15:46:06 PDT 2016
Author: rnk
Date: Wed Apr 13 17:46:06 2016
New Revision: 266256
URL: http://llvm.org/viewvc/llvm-project?rev=266256&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/IR/Metadata.h
Modified: llvm/trunk/include/llvm/IR/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Metadata.h?rev=266256&r1=266255&r2=266256&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Metadata.h (original)
+++ llvm/trunk/include/llvm/IR/Metadata.h Wed Apr 13 17:46:06 2016
@@ -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;
More information about the llvm-commits
mailing list