diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h @@ -43,6 +43,7 @@ }; struct ChainedOriginDepotNode { + using hash_type = u32; ChainedOriginDepotNode *link; u32 id; u32 here_id; @@ -50,15 +51,15 @@ typedef ChainedOriginDepotDesc args_type; - bool eq(u32 hash, const args_type &args) const; + bool eq(hash_type hash, const args_type &args) const; static uptr storage_size(const args_type &args); - static u32 hash(const args_type &args); + static hash_type hash(const args_type &args); static bool is_valid(const args_type &args); - void store(const args_type &args, u32 other_hash); + void store(const args_type &args, hash_type other_hash); args_type load() const; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp @@ -14,7 +14,7 @@ namespace __sanitizer { bool ChainedOriginDepot::ChainedOriginDepotNode::eq( - u32 hash, const args_type &args) const { + hash_type hash, const args_type &args) const { return here_id == args.here_id && prev_id == args.prev_id; } @@ -36,7 +36,8 @@ split, or one of two reserved values (-1) or (-2). Either case can dominate depending on the workload. */ -u32 ChainedOriginDepot::ChainedOriginDepotNode::hash(const args_type &args) { +ChainedOriginDepot::ChainedOriginDepotNode::hash_type +ChainedOriginDepot::ChainedOriginDepotNode::hash(const args_type &args) { const u32 m = 0x5bd1e995; const u32 seed = 0x9747b28c; const u32 r = 24; @@ -67,7 +68,7 @@ } void ChainedOriginDepot::ChainedOriginDepotNode::store(const args_type &args, - u32 other_hash) { + hash_type other_hash) { here_id = args.here_id; prev_id = args.prev_id; } 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 @@ -19,9 +19,10 @@ namespace __sanitizer { struct StackDepotNode { + using hash_type = u32; StackDepotNode *link; u32 id; - u32 stack_hash; + hash_type stack_hash; u32 size; atomic_uint32_t tag_and_use_count; // tag : 12 high bits; use_count : 20; uptr stack[1]; // [size] @@ -32,7 +33,7 @@ static const u32 kUseCountMask = (1 << kUseCountBits) - 1; typedef StackTrace args_type; - bool eq(u32 hash, const args_type &args) const { + 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) @@ -46,7 +47,7 @@ static uptr storage_size(const args_type &args) { return sizeof(StackDepotNode) + (args.size - 1) * sizeof(uptr); } - static u32 hash(const args_type &args) { + static hash_type hash(const args_type &args) { MurMur2HashBuilder H(args.size * sizeof(uptr)); for (uptr i = 0; i < args.size; i++) H.add(args.trace[i]); return H.get(); @@ -54,7 +55,7 @@ static bool is_valid(const args_type &args) { return args.size > 0 && args.trace; } - void store(const args_type &args, u32 hash) { + void store(const args_type &args, hash_type hash) { CHECK_EQ(args.tag & (~kUseCountMask >> kUseCountBits), args.tag); atomic_store(&tag_and_use_count, args.tag << kUseCountBits, memory_order_relaxed); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h --- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h @@ -27,6 +27,7 @@ public: typedef typename Node::args_type args_type; typedef typename Node::handle_type handle_type; + typedef typename Node::hash_type hash_type; // Maps stack trace to an unique id. handle_type Put(args_type args, bool *inserted = nullptr); // Retrieves a stored stack trace by the id. @@ -39,7 +40,7 @@ void PrintAll(); private: - static Node *find(Node *s, args_type args, u32 hash); + static Node *find(Node *s, args_type args, hash_type hash); static Node *lock(atomic_uintptr_t *p); static void unlock(atomic_uintptr_t *p, Node *s); @@ -62,7 +63,7 @@ template Node *StackDepotBase::find(Node *s, args_type args, - u32 hash) { + hash_type hash) { // Searches linked list s for the stack, returns its id. for (; s; s = s->link) { if (s->eq(hash, args)) { @@ -101,7 +102,7 @@ bool *inserted) { if (inserted) *inserted = false; if (!Node::is_valid(args)) return handle_type(); - uptr h = Node::hash(args); + hash_type h = Node::hash(args); atomic_uintptr_t *p = &tab[h % kTabSize]; uptr v = atomic_load(p, memory_order_consume); Node *s = (Node *)(v & ~1);