Skip to content

Commit 8502176

Browse files
committed
[sanitizer] Remove tag from StackDepotNode
And share storage with size. Depends on D111615. Differential Revision: https://reviews.llvm.org/D111616
1 parent e5859af commit 8502176

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ struct StackDepotNode {
2525
using hash_type = u64;
2626
hash_type stack_hash;
2727
u32 link;
28-
u32 tag;
2928

3029
static const u32 kTabSizeLog = SANITIZER_ANDROID ? 16 : 20;
30+
static const u32 kStackSizeBits = 16;
3131

3232
typedef StackTrace args_type;
3333
bool eq(hash_type hash, const args_type &args) const {
@@ -78,10 +78,10 @@ uptr StackDepotNode::allocated() {
7878
}
7979

8080
void StackDepotNode::store(u32 id, const args_type &args, hash_type hash) {
81-
tag = args.tag;
8281
stack_hash = hash;
8382
uptr *stack_trace = traceAllocator.alloc(args.size + 1);
84-
*stack_trace = args.size;
83+
CHECK_LT(args.size, 1 << kStackSizeBits);
84+
*stack_trace = args.size + (args.tag << kStackSizeBits);
8585
internal_memcpy(stack_trace + 1, args.trace, args.size * sizeof(uptr));
8686
tracePtrs[id] = stack_trace;
8787
}
@@ -90,7 +90,9 @@ StackDepotNode::args_type StackDepotNode::load(u32 id) const {
9090
const uptr *stack_trace = tracePtrs[id];
9191
if (!stack_trace)
9292
return {};
93-
return args_type(stack_trace + 1, *stack_trace, tag);
93+
uptr size = *stack_trace & ((1 << kStackSizeBits) - 1);
94+
uptr tag = *stack_trace >> kStackSizeBits;
95+
return args_type(stack_trace + 1, size, tag);
9496
}
9597

9698
StackDepotStats StackDepotGetStats() { return theDepot.GetStats(); }

0 commit comments

Comments
 (0)