Skip to content

Commit bee74f1

Browse files
committed
first round of comments
1 parent 6bc36e1 commit bee74f1

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

bolt/include/bolt/Core/DebugData.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,9 @@ class DebugStrOffsetsWriter {
441441

442442
/// Get offset for given index in original .debug_str_offsets section.
443443
uint64_t getOffset(uint32_t Index) const {
444-
assert(StrOffsets.size() > Index && "Index is out of bounds.");
444+
assert(StrOffsets.size() >= Index && "Index is out of bounds.");
445445
return StrOffsets[Index];
446446
}
447-
448447
/// Writes out current sections entry into .debug_str_offsets.
449448
void finalizeSection(DWARFUnit &Unit, DIEBuilder &DIEBldr);
450449

@@ -811,7 +810,6 @@ class DwarfLineTable {
811810
// Returns DWARF Version for this line table.
812811
uint16_t getDwarfVersion() const { return DwarfVersion; }
813812
};
814-
815813
} // namespace bolt
816814
} // namespace llvm
817815

bolt/include/bolt/Core/DebugNames.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- bolt/Core/DebugNames.cpp - Debugging information handling ---*- C++
1+
//===- bolt/Core/DebugNames.h - Debug names support ---*- C++
22
//-*-===//
33
//
44
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.

bolt/lib/Core/DebugNames.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void DWARF5AcceleratorTable::setCurrentUnit(DWARFUnit &Unit,
6666
CurrentUnit = nullptr;
6767
CurrentUnitOffset = UnitStartOffset;
6868
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.
7070
// Patching offset in CU list to correct one.
7171
if (!Unit.isDWOUnit() && DWOID) {
7272
auto Iter = CUOffsetsToPatch.find(*DWOID);
@@ -289,14 +289,6 @@ void DWARF5AcceleratorTable::computeBucketCount() {
289289
void DWARF5AcceleratorTable::finalize() {
290290
if (!NeedToCreate)
291291
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-
}
300292
// Figure out how many buckets we need, then compute the bucket contents and
301293
// the final ordering. The hashes and offsets can be emitted by walking these
302294
// data structures.
@@ -311,10 +303,16 @@ void DWARF5AcceleratorTable::finalize() {
311303

312304
// Sort the contents of the buckets by hash value so that hash collisions end
313305
// 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) {
316308
return LHS->HashValue < RHS->HashValue;
317309
});
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+
}
318316

319317
CUIndexForm = DIEInteger::BestForm(/*IsSigned*/ false, CUList.size() - 1);
320318
TUIndexForm = DIEInteger::BestForm(
@@ -416,7 +414,7 @@ void DWARF5AcceleratorTable::writeEntry(const BOLTDWARF5AccelTableData &Entry) {
416414
getAbbrevIndex(Entry.getDieTag(), EntryRet, SecondEntryRet);
417415
auto AbbrevIt = Abbreviations.find(TagIndexVal);
418416
assert(AbbrevIt != Abbreviations.end() &&
419-
"Why wasn't this abbrev generated?");
417+
"Abbrev tag was not found in the abbreviation map!");
420418
encodeULEB128(TagIndexVal.Index, *Entriestream);
421419
auto writeIndex = [&](uint32_t Index, uint32_t IndexSize) -> void {
422420
switch (IndexSize) {

0 commit comments

Comments
 (0)