From c15139bb6d47e1ae36b0828e37e3593ce621b2fc Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 30 Jun 2015 00:10:54 +0000 Subject: COFF: Make DefinedCOFF one pointer smaller. The size of this class actually matters because this is the most popular class among all classes. We create a Defined symbol for each defined symbol in a symbol table. That can be millions for a large program. For example, linking LLD instantiates this class millions times. llvm-svn: 241025 --- lld/COFF/Symbols.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lld/COFF') diff --git a/lld/COFF/Symbols.h b/lld/COFF/Symbols.h index db2aa1eb32b8..58e025689fef 100644 --- a/lld/COFF/Symbols.h +++ b/lld/COFF/Symbols.h @@ -25,6 +25,7 @@ namespace coff { using llvm::object::Archive; using llvm::object::COFFSymbolRef; using llvm::object::coff_import_header; +using llvm::object::coff_symbol_generic; class ArchiveFile; class InputFile; @@ -131,7 +132,7 @@ class DefinedCOFF : public Defined { friend SymbolBody; public: DefinedCOFF(Kind K, ObjectFile *F, COFFSymbolRef S) - : Defined(K), File(F), Sym(S) {} + : Defined(K), File(F), Sym(S.getGeneric()) {} static bool classof(const SymbolBody *S) { return S->kind() <= LastDefinedCOFFKind; @@ -139,7 +140,7 @@ public: protected: ObjectFile *File; - COFFSymbolRef Sym; + const coff_symbol_generic *Sym; }; // Regular defined symbols read from object file symbol tables. @@ -147,7 +148,7 @@ class DefinedRegular : public DefinedCOFF { public: DefinedRegular(ObjectFile *F, COFFSymbolRef S, SectionChunk *C) : DefinedCOFF(DefinedRegularKind, F, S), Data(&C->Ptr) { - IsExternal = Sym.isExternal(); + IsExternal = S.isExternal(); IsCOMDAT = C->isCOMDAT(); } @@ -156,15 +157,15 @@ public: } uint64_t getFileOff() { - return (*Data)->getFileOff() + Sym.getValue(); + return (*Data)->getFileOff() + Sym->Value; } - uint64_t getRVA() { return (*Data)->getRVA() + Sym.getValue(); } + uint64_t getRVA() { return (*Data)->getRVA() + Sym->Value; } bool isCOMDAT() { return IsCOMDAT; } bool isLive() const { return (*Data)->isLive(); } void markLive() { (*Data)->markLive(); } SectionChunk *getChunk() { return *Data; } - uint64_t getValue() { return Sym.getValue(); } + uint32_t getValue() { return Sym->Value; } private: SectionChunk **Data; @@ -174,7 +175,7 @@ class DefinedCommon : public DefinedCOFF { public: DefinedCommon(ObjectFile *F, COFFSymbolRef S, CommonChunk *C) : DefinedCOFF(DefinedCommonKind, F, S), Data(C) { - IsExternal = Sym.isExternal(); + IsExternal = S.isExternal(); } static bool classof(const SymbolBody *S) { @@ -187,7 +188,7 @@ public: private: friend SymbolBody; - uint64_t getSize() { return Sym.getValue(); } + uint64_t getSize() { return Sym->Value; } CommonChunk *Data; }; -- cgit v1.2.3