[llvm] r238003 - MC: Pack MCSymbol::Index in with the bitfield in MCSymbol

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu May 21 22:59:05 PDT 2015


Author: dexonsmith
Date: Fri May 22 00:59:05 2015
New Revision: 238003

URL: http://llvm.org/viewvc/llvm-project?rev=238003&view=rev
Log:
MC: Pack MCSymbol::Index in with the bitfield in MCSymbol

Save a pointer for each `MCSymbol`, bringing `llc` memory usage down
from 920 MB to 914 MB, around ~0.6%.

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

Modified:
    llvm/trunk/include/llvm/MC/MCSymbol.h

Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=238003&r1=238002&r2=238003&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Fri May 22 00:59:05 2015
@@ -167,17 +167,18 @@ class MCSymbol {
   mutable unsigned IsUsed : 1;
 
   mutable bool HasData : 1;
-  mutable MCSymbolData Data;
 
   /// Index field, for use by the object file implementation.
-  mutable uint64_t Index = 0;
+  mutable uint64_t Index : 60;
+
+  mutable MCSymbolData Data;
 
 private: // MCContext creates and uniques these.
   friend class MCExpr;
   friend class MCContext;
   MCSymbol(StringRef name, bool isTemporary)
       : Name(name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
-        IsRedefinable(false), IsUsed(false), HasData(false) {}
+        IsRedefinable(false), IsUsed(false), HasData(false), Index(0) {}
 
   MCSymbol(const MCSymbol &) = delete;
   void operator=(const MCSymbol &) = delete;
@@ -290,6 +291,7 @@ public:
   /// Set the (implementation defined) index.
   void setIndex(uint64_t Value) const {
     assert(HasData && "Uninitialized symbol data");
+    assert(!(Value >> 60) && "Not enough bits for value");
     Index = Value;
   }
 





More information about the llvm-commits mailing list