diff options
| author | Pavel Labath <labath@google.com> | 2018-02-09 10:06:56 +0000 |
|---|---|---|
| committer | Pavel Labath <labath@google.com> | 2018-02-09 10:06:56 +0000 |
| commit | 062eb53781e6b00ed02ac2c1ae3a77a6db08b94d (patch) | |
| tree | 55b8add341eba31fdfa6ad8e808281b9c56a287f /llvm/include | |
| parent | a1181312ea94446f23b20ca78a0dcd96348fe7de (diff) | |
| download | bcm5719-llvm-062eb53781e6b00ed02ac2c1ae3a77a6db08b94d.tar.gz bcm5719-llvm-062eb53781e6b00ed02ac2c1ae3a77a6db08b94d.zip | |
[CodeGen] Optimize AccelTable
Summary:
The class contained arrays of two structures (DataArray and HashData).
These structures were in 1:1 correspondence, and one of them contained
pointers to the other (and *both* contained a "Name" field). By merging
these two structures into one, we can save a bit of space without
negatively impacting much of anything.
Reviewers: JDevlieghere, aprantl
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D43073
llvm-svn: 324724
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/CodeGen/AccelTable.h | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h index 9c8a7215e2b..9fa4b5ca656 100644 --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -214,26 +214,19 @@ protected: /// Apple-style accelerator table base class. class AppleAccelTableBase { protected: - struct DataArray { - DwarfStringPoolEntryRef Name; - std::vector<AppleAccelTableData *> Values; - }; - - friend struct HashData; - struct HashData { - StringRef Str; + DwarfStringPoolEntryRef Name; uint32_t HashValue; + std::vector<AppleAccelTableData *> Values; MCSymbol *Sym; - DataArray &Data; - HashData(StringRef S, DataArray &Data) : Str(S), Data(Data) { - HashValue = djbHash(S); + HashData(DwarfStringPoolEntryRef Name) : Name(Name) { + HashValue = djbHash(Name.getString()); } #ifndef NDEBUG - void print(raw_ostream &OS); - void dump() { print(dbgs()); } + void print(raw_ostream &OS) const; + void dump() const { print(dbgs()); } #endif }; @@ -243,9 +236,7 @@ protected: /// Header containing both the header and header data. AppleAccelTableHeader Header; - std::vector<HashData *> Data; - - using StringEntries = StringMap<DataArray, BumpPtrAllocator &>; + using StringEntries = StringMap<HashData, BumpPtrAllocator &>; StringEntries Entries; using HashList = std::vector<HashData *>; @@ -323,13 +314,12 @@ template <typename AppleAccelTableDataT> template <class... Types> void AppleAccelTable<AppleAccelTableDataT>::addName( DwarfStringPoolEntryRef Name, Types... Args) { - assert(Data.empty() && "Already finalized!"); + assert(Buckets.empty() && "Already finalized!"); // If the string is in the list already then add this die to the list // otherwise add a new one. - DataArray &DA = Entries[Name.getString()]; - assert(!DA.Name || DA.Name == Name); - DA.Name = Name; - DA.Values.push_back(new (Allocator) AppleAccelTableDataT(Args...)); + auto Iter = Entries.try_emplace(Name.getString(), Name).first; + assert(Iter->second.Name == Name); + Iter->second.Values.push_back(new (Allocator) AppleAccelTableDataT(Args...)); } /// Accelerator table data implementation for simple accelerator tables with |

