mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 22:24:28 +00:00
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.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -676,7 +676,7 @@ class MCAssembler {
|
||||
|
||||
public:
|
||||
typedef iplist<MCSectionData> SectionDataListType;
|
||||
typedef std::vector<std::unique_ptr<MCSymbolData>> SymbolDataListType;
|
||||
typedef std::vector<MCSymbolData *> SymbolDataListType;
|
||||
|
||||
typedef SectionDataListType::const_iterator const_iterator;
|
||||
typedef SectionDataListType::iterator iterator;
|
||||
@ -734,11 +734,6 @@ private:
|
||||
// FIXME: Avoid this indirection?
|
||||
DenseMap<const MCSection *, MCSectionData *> SectionMap;
|
||||
|
||||
/// The map of symbols to their associated assembler backend data.
|
||||
//
|
||||
// FIXME: Avoid this indirection?
|
||||
DenseMap<const MCSymbol *, MCSymbolData *> SymbolMap;
|
||||
|
||||
std::vector<IndirectSymbolData> IndirectSymbols;
|
||||
|
||||
std::vector<DataRegionData> DataRegions;
|
||||
@ -1039,7 +1034,7 @@ public:
|
||||
}
|
||||
|
||||
bool hasSymbolData(const MCSymbol &Symbol) const {
|
||||
return SymbolMap.lookup(&Symbol) != nullptr;
|
||||
return Symbol.getUnsafeData().isInitialized();
|
||||
}
|
||||
|
||||
MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
|
||||
@ -1048,23 +1043,18 @@ public:
|
||||
}
|
||||
|
||||
const MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
|
||||
MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
|
||||
assert(Entry && "Missing symbol data!");
|
||||
return *Entry;
|
||||
return Symbol.getData();
|
||||
}
|
||||
|
||||
MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
|
||||
bool *Created = nullptr) {
|
||||
MCSymbolData *&Entry = SymbolMap[&Symbol];
|
||||
|
||||
if (Created)
|
||||
*Created = !Entry;
|
||||
if (!Entry) {
|
||||
Symbols.emplace_back(new MCSymbolData(Symbol, nullptr, 0));
|
||||
Entry = Symbols.back().get();
|
||||
*Created = !hasSymbolData(Symbol);
|
||||
if (!hasSymbolData(Symbol)) {
|
||||
Symbol.getUnsafeData().initialize(Symbol, nullptr, 0);
|
||||
Symbols.push_back(&Symbol.getData());
|
||||
}
|
||||
|
||||
return *Entry;
|
||||
return Symbol.getData();
|
||||
}
|
||||
|
||||
const_file_name_iterator file_names_begin() const {
|
||||
|
Reference in New Issue
Block a user