MC: Merge MCSymbol and MCSymbolData
Turn `MCSymbolData` into a field inside of `MCSymbol`. Keep all the old
API alive for now, so that consumers can be updated in a later commit.
This means we still temporarily need the back pointer from
`MCSymbolData` to `MCSymbol`, but I'll remove it in a follow-up.
This optimizes for object emission over assembly emission. By removing
the `DenseMap` in `MCAssembler`, llc memory usage drops from around 1040
MB to 1001 MB (3.8%).
(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)
llvm-svn: 237490
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index b4b9a47..ff230dfd 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -360,10 +360,18 @@
MCSymbolData::MCSymbolData() : Symbol(nullptr) {}
-MCSymbolData::MCSymbolData(const MCSymbol &Symbol, MCFragment *Fragment,
- uint64_t Offset)
- : Symbol(&Symbol), Fragment(Fragment), Offset(Offset), SymbolSize(nullptr),
- CommonAlign(-1U), Flags(0), Index(0) {}
+void MCSymbolData::initialize(const MCSymbol &Symbol, MCFragment *Fragment,
+ uint64_t Offset) {
+ assert(!isInitialized() && "Expected uninitialized symbol");
+
+ this->Symbol = &Symbol;
+ this->Fragment.setPointer(Fragment);
+ this->Offset = Offset;
+ this->SymbolSize = nullptr;
+ this->CommonAlign = -1U;
+ this->Flags = 0;
+ this->Index = 0;
+}
/* *** */
@@ -383,7 +391,6 @@
Sections.clear();
Symbols.clear();
SectionMap.clear();
- SymbolMap.clear();
IndirectSymbols.clear();
DataRegions.clear();
LinkerOptions.clear();