[compiler-rt] b5b1b3a - [sanitizer] Switch to StackDepotNode to 64bit hash
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 6 10:45:20 PDT 2021
Author: Vitaly Buka
Date: 2021-10-06T10:45:11-07:00
New Revision: b5b1b3aef1f3cdd8c7707280678e34d8b0baa11d
URL: https://github.com/llvm/llvm-project/commit/b5b1b3aef1f3cdd8c7707280678e34d8b0baa11d
DIFF: https://github.com/llvm/llvm-project/commit/b5b1b3aef1f3cdd8c7707280678e34d8b0baa11d.diff
LOG: [sanitizer] Switch to StackDepotNode to 64bit hash
Now we can avoid scanning the stack on fast path.
The price is the false stack trace with probability of the hash collision.
This increase performance of lsan by 6% and pre-requirement for stack compression.
Depends on D111182.
Reviewed By: morehouse, dvyukov
Differential Revision: https://reviews.llvm.org/D111183
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
index fc2ea2fc768f..6d24df14d821 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -19,10 +19,10 @@
namespace __sanitizer {
struct StackDepotNode {
- using hash_type = u32;
+ using hash_type = u64;
+ hash_type stack_hash;
StackDepotNode *link;
u32 id;
- hash_type stack_hash;
u32 size;
atomic_uint32_t tag_and_use_count; // tag : 12 high bits; use_count : 20;
uptr stack[1]; // [size]
@@ -34,22 +34,15 @@ struct StackDepotNode {
typedef StackTrace args_type;
bool eq(hash_type hash, const args_type &args) const {
- u32 tag =
- atomic_load(&tag_and_use_count, memory_order_relaxed) >> kUseCountBits;
- if (stack_hash != hash || args.size != size || args.tag != tag)
- return false;
- uptr i = 0;
- for (; i < size; i++) {
- if (stack[i] != args.trace[i]) return false;
- }
- return true;
+ return hash == stack_hash;
}
static uptr storage_size(const args_type &args) {
return sizeof(StackDepotNode) + (args.size - 1) * sizeof(uptr);
}
static hash_type hash(const args_type &args) {
- MurMur2HashBuilder H(args.size * sizeof(uptr));
+ MurMur2Hash64Builder H(args.size * sizeof(uptr));
for (uptr i = 0; i < args.size; i++) H.add(args.trace[i]);
+ H.add(args.tag);
return H.get();
}
static bool is_valid(const args_type &args) {
More information about the llvm-commits
mailing list