diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp @@ -24,9 +24,9 @@ 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 { @@ -53,8 +53,7 @@ typedef StackDepotBase StackDepot; static StackDepot theDepot; -static TwoLevelMap +static TwoLevelMap tracePtrs; static TwoLevelMap @@ -69,10 +68,10 @@ } 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; } @@ -81,7 +80,9 @@ 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(); }