[llvm] [DebugNames] Use hashes to quickly filter false positives (PR #79755)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 28 07:36:42 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
Author: Felipe de Azevedo Piovezan (felipepiovezan)
<details>
<summary>Changes</summary>
The current implementation of DebugNames is _only_ using hashes to compute the bucket number. Once inside the bucket, it reverts back to string comparisons, even though not all hashes inside a bucket are identical.
This commit changes the behavior so that we check the hash before comparing strings. Such check is so important that it speeds up a simple benchmark by 20%. In other words, the following expression evaluation time goes from 1100ms to 850ms.
```
bin/lldb \
--batch \
-o "b CodeGenFunction::GenerateCode" \
-o run \
-o "expr Fn" \
-- \
clang++ -c -g test.cpp -o /dev/null &> output
```
(Note, these numbers are considering the usage of IDX_parent)
---
Full diff: https://github.com/llvm/llvm-project/pull/79755.diff
1 Files Affected:
- (modified) llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (+4-2)
``````````diff
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 03ad5d133caddf..a1a1ac093aa5c1 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -937,9 +937,11 @@ DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() {
return std::nullopt; // Empty bucket
for (; Index <= Hdr.NameCount; ++Index) {
- uint32_t Hash = CurrentIndex->getHashArrayEntry(Index);
- if (Hash % Hdr.BucketCount != Bucket)
+ uint32_t HashAtIndex = CurrentIndex->getHashArrayEntry(Index);
+ if (HashAtIndex % Hdr.BucketCount != Bucket)
return std::nullopt; // End of bucket
+ if (HashAtIndex != Hash)
+ continue;
NameTableEntry NTE = CurrentIndex->getNameTableEntry(Index);
if (NTE.getString() == Key)
``````````
</details>
https://github.com/llvm/llvm-project/pull/79755
More information about the llvm-commits
mailing list