diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-06-09 18:36:13 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-06-09 18:36:13 +0000 |
commit | 234b87569048e2bea9ab4f3fa444239b658faf7a (patch) | |
tree | 3ab4dc54c80348367304da6eb849a7f9e93d54ad /llvm/lib/MC/MCContext.cpp | |
parent | 7e226271a1aef7c73ac0bb980fd36a13a448f8aa (diff) | |
download | llvm-234b87569048e2bea9ab4f3fa444239b658faf7a.zip llvm-234b87569048e2bea9ab4f3fa444239b658faf7a.tar.gz llvm-234b87569048e2bea9ab4f3fa444239b658faf7a.tar.bz2 |
Allocate space for MCSymbol::Name only if required.
Similarly to User which allocates a number of Use's prior to the this pointer,
allocate space for the Name* for MCSymbol only when we need a name.
Given that an MCSymbol is 48-bytes on 64-bit systems, this saves a decent % of space.
Given the verify_uselistorder test case with debug info and llc, 50k symbols have names
out of 700k so this optimises for the common case of temporary unnamed symbols.
Reviewed by David Blaikie.
llvm-svn: 239423
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 1e52eed..785f9ac 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -135,7 +135,7 @@ MCSymbolELF *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) { } auto NameIter = UsedNames.insert(std::make_pair(Name, true)).first; - Sym = new (*this) MCSymbolELF(&*NameIter, /*isTemporary*/ false); + Sym = new (&*NameIter, *this) MCSymbolELF(&*NameIter, /*isTemporary*/ false); if (!OldSym) OldSym = Sym; @@ -164,14 +164,15 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name, if (MOFI) { switch (MOFI->getObjectFileType()) { case MCObjectFileInfo::IsCOFF: - return new (*this) MCSymbolCOFF(Name, IsTemporary); + return new (Name, *this) MCSymbolCOFF(Name, IsTemporary); case MCObjectFileInfo::IsELF: - return new (*this) MCSymbolELF(Name, IsTemporary); + return new (Name, *this) MCSymbolELF(Name, IsTemporary); case MCObjectFileInfo::IsMachO: - return new (*this) MCSymbolMachO(Name, IsTemporary); + return new (Name, *this) MCSymbolMachO(Name, IsTemporary); } } - return new (*this) MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary); + return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name, + IsTemporary); } MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix, |