[compiler-rt] 8502176 - [sanitizer] Remove tag from StackDepotNode
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 24 13:55:52 PDT 2021
Author: Vitaly Buka
Date: 2021-10-24T13:38:22-07:00
New Revision: 850217686e211f9515d60f31e31bc4171f544239
URL: https://github.com/llvm/llvm-project/commit/850217686e211f9515d60f31e31bc4171f544239
DIFF: https://github.com/llvm/llvm-project/commit/850217686e211f9515d60f31e31bc4171f544239.diff
LOG: [sanitizer] Remove tag from StackDepotNode
And share storage with size.
Depends on D111615.
Differential Revision: https://reviews.llvm.org/D111616
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 606197240b7c..02855459922d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -25,9 +25,9 @@ struct StackDepotNode {
using hash_type = u64;
hash_type stack_hash;
u32 link;
- u32 tag;
static const u32 kTabSizeLog = SANITIZER_ANDROID ? 16 : 20;
+ static const u32 kStackSizeBits = 16;
typedef StackTrace args_type;
bool eq(hash_type hash, const args_type &args) const {
@@ -78,10 +78,10 @@ uptr StackDepotNode::allocated() {
}
void StackDepotNode::store(u32 id, const args_type &args, hash_type hash) {
- tag = args.tag;
stack_hash = hash;
uptr *stack_trace = traceAllocator.alloc(args.size + 1);
- *stack_trace = args.size;
+ CHECK_LT(args.size, 1 << kStackSizeBits);
+ *stack_trace = args.size + (args.tag << kStackSizeBits);
internal_memcpy(stack_trace + 1, args.trace, args.size * sizeof(uptr));
tracePtrs[id] = stack_trace;
}
@@ -90,7 +90,9 @@ StackDepotNode::args_type StackDepotNode::load(u32 id) const {
const uptr *stack_trace = tracePtrs[id];
if (!stack_trace)
return {};
- return args_type(stack_trace + 1, *stack_trace, tag);
+ uptr size = *stack_trace & ((1 << kStackSizeBits) - 1);
+ uptr tag = *stack_trace >> kStackSizeBits;
+ return args_type(stack_trace + 1, size, tag);
}
StackDepotStats StackDepotGetStats() { return theDepot.GetStats(); }
More information about the llvm-commits
mailing list