Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. #83047

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions llvm/include/llvm/BinaryFormat/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,21 +615,21 @@ enum AcceleratorTable {

// Uniquify the string hashes and calculate the bucket count for the
// DWARF v5 Accelerator Table. NOTE: This function effectively consumes the
// 'hashes' input parameter.
inline uint32_t getDebugNamesBucketCount(MutableArrayRef<uint32_t> hashes,
uint32_t &uniqueHashCount) {
// 'Hashes' input parameter.
inline std::pair<uint32_t, uint32_t>
getDebugNamesBucketAndHashCount(MutableArrayRef<uint32_t> Hashes) {
uint32_t BucketCount = 0;

sort(hashes);
uniqueHashCount = llvm::unique(hashes) - hashes.begin();
if (uniqueHashCount > 1024)
BucketCount = uniqueHashCount / 4;
else if (uniqueHashCount > 16)
BucketCount = uniqueHashCount / 2;
sort(Hashes);
uint32_t UniqueHashCount = llvm::unique(Hashes) - Hashes.begin();
if (UniqueHashCount > 1024)
BucketCount = UniqueHashCount / 4;
else if (UniqueHashCount > 16)
BucketCount = UniqueHashCount / 2;
else
BucketCount = std::max<uint32_t>(uniqueHashCount, 1);
BucketCount = std::max<uint32_t>(UniqueHashCount, 1);

return BucketCount;
return {BucketCount, UniqueHashCount};
}

// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ void AccelTableBase::computeBucketCount() {
for (const auto &E : Entries)
Uniques.push_back(E.second.HashValue);

BucketCount = llvm::dwarf::getDebugNamesBucketCount(Uniques, UniqueHashCount);
auto Counts = llvm::dwarf::getDebugNamesBucketAndHashCount(Uniques);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to std::tie(BucketCount, UniqueHashCount)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this - @cmtice perhaps you could make this change as a follow-up commit. No need to send it for review. (but please follow up on this comment thread and mention the commit hash of the change once it's upstream)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the simplification already. Sometimes reviewers may click "Accept" and expect some minor code suggestions will be adopted before landing. It's worth paying attention to these comments.

(For both #82153 and this #83047, my comments were created before the patch landed. Don't worry. We all made mistakes.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, 7b0b64a cool, thanks!

BucketCount = Counts.first;
UniqueHashCount = Counts.second;
}

void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {
Expand Down
Loading