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 2 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
16 changes: 8 additions & 8 deletions llvm/include/llvm/BinaryFormat/Dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,20 +616,20 @@ 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) {
uint32_t BucketCount = 0;
inline std::pair<uint32_t, uint32_t>
getDebugNamesBucketAndHashCount(MutableArrayRef<uint32_t> hashes) {
uint32_t bucketCount = 0;
Copy link
Member

@JDevlieghere JDevlieghere Feb 26, 2024

Choose a reason for hiding this comment

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

Why did you change the case? Doesn't LLVM use UpperCamelCase for variables?

Copy link
Contributor

Choose a reason for hiding this comment

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

good point, I had missed this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought LLVM variables were supposed to start with lower case? So I thought I was fixing a problem? I can switch it back if you think I should...

Copy link
Member

Choose a reason for hiding this comment

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

You're probably thinking of functions, which (unlink LLDB) use lowerCamelCase: https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Done.


sort(hashes);
uniqueHashCount = llvm::unique(hashes) - hashes.begin();
uint32_t uniqueHashCount = llvm::unique(hashes) - hashes.begin();
if (uniqueHashCount > 1024)
BucketCount = uniqueHashCount / 4;
bucketCount = uniqueHashCount / 4;
else if (uniqueHashCount > 16)
BucketCount = uniqueHashCount / 2;
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);
BucketCount = counts.first;
UniqueHashCount = counts.second;
}

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