@@ -66,7 +66,7 @@ void DWARF5AcceleratorTable::setCurrentUnit(DWARFUnit &Unit,
66
66
CurrentUnit = nullptr ;
67
67
CurrentUnitOffset = UnitStartOffset;
68
68
std::optional<uint64_t > DWOID = Unit.getDWOId ();
69
- // We process Skelton CUs after DWO Units for it.
69
+ // We process skeleton CUs after DWO Units for it.
70
70
// Patching offset in CU list to correct one.
71
71
if (!Unit.isDWOUnit () && DWOID) {
72
72
auto Iter = CUOffsetsToPatch.find (*DWOID);
@@ -289,14 +289,6 @@ void DWARF5AcceleratorTable::computeBucketCount() {
289
289
void DWARF5AcceleratorTable::finalize () {
290
290
if (!NeedToCreate)
291
291
return ;
292
- // Create the individual hash data outputs.
293
- for (auto &E : Entries) {
294
- // Unique the entries.
295
- llvm::stable_sort (E.second .Values , [](const BOLTDWARF5AccelTableData *A,
296
- const BOLTDWARF5AccelTableData *B) {
297
- return A->getDieOffset () < B->getDieOffset ();
298
- });
299
- }
300
292
// Figure out how many buckets we need, then compute the bucket contents and
301
293
// the final ordering. The hashes and offsets can be emitted by walking these
302
294
// data structures.
@@ -311,10 +303,16 @@ void DWARF5AcceleratorTable::finalize() {
311
303
312
304
// Sort the contents of the buckets by hash value so that hash collisions end
313
305
// up together. Stable sort makes testing easier and doesn't cost much more.
314
- for (auto &Bucket : Buckets)
315
- llvm::stable_sort (Bucket, [](HashData *LHS, HashData *RHS) {
306
+ for (HashList &Bucket : Buckets) {
307
+ llvm::stable_sort (Bucket, [](const HashData *LHS, const HashData *RHS) {
316
308
return LHS->HashValue < RHS->HashValue ;
317
309
});
310
+ for (HashData *H : Bucket)
311
+ llvm::stable_sort (H->Values , [](const BOLTDWARF5AccelTableData *LHS,
312
+ const BOLTDWARF5AccelTableData *RHS) {
313
+ return LHS->getDieOffset () < RHS->getDieOffset ();
314
+ });
315
+ }
318
316
319
317
CUIndexForm = DIEInteger::BestForm (/* IsSigned*/ false , CUList.size () - 1 );
320
318
TUIndexForm = DIEInteger::BestForm (
@@ -416,7 +414,7 @@ void DWARF5AcceleratorTable::writeEntry(const BOLTDWARF5AccelTableData &Entry) {
416
414
getAbbrevIndex (Entry.getDieTag (), EntryRet, SecondEntryRet);
417
415
auto AbbrevIt = Abbreviations.find (TagIndexVal);
418
416
assert (AbbrevIt != Abbreviations.end () &&
419
- " Why wasn't this abbrev generated? " );
417
+ " Abbrev tag was not found in the abbreviation map! " );
420
418
encodeULEB128 (TagIndexVal.Index , *Entriestream);
421
419
auto writeIndex = [&](uint32_t Index, uint32_t IndexSize) -> void {
422
420
switch (IndexSize) {
0 commit comments