[compiler-rt] 168bc7c - [sanitizer] Remove storeIds and use padding of StackDepotNode

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 28 01:58:59 PST 2021


Author: Vitaly Buka
Date: 2021-11-28T01:58:49-08:00
New Revision: 168bc7ce7e2ebe6527bf3fdd9262ef5c0deab4fc

URL: https://github.com/llvm/llvm-project/commit/168bc7ce7e2ebe6527bf3fdd9262ef5c0deab4fc
DIFF: https://github.com/llvm/llvm-project/commit/168bc7ce7e2ebe6527bf3fdd9262ef5c0deab4fc.diff

LOG: [sanitizer] Remove storeIds and use padding of StackDepotNode

Depends on D114489.

Reviewed By: morehouse, dvyukov

Differential Revision: https://reviews.llvm.org/D114490

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
index 8f1f95224dba..54b1141ced1d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stack_store.cpp
@@ -50,7 +50,7 @@ StackTrace StackStore::Load(Id id) const {
   uptr idx = IdToOffset(id);
   uptr block_idx = GetBlockIdx(idx);
   CHECK_LT(block_idx, ARRAY_SIZE(blocks_));
-  uptr *stack_trace = blocks_[block_idx].Get();
+  const uptr *stack_trace = blocks_[block_idx].Get();
   if (!stack_trace)
     return {};
   stack_trace += GetInBlockIdx(idx);

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
index e203b2cc4c89..8e1832f07398 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -23,6 +23,7 @@ struct StackDepotNode {
   using hash_type = u64;
   hash_type stack_hash;
   u32 link;
+  StackStore::Id store_id;
 
   static const u32 kTabSizeLog = SANITIZER_ANDROID ? 16 : 20;
 
@@ -53,11 +54,6 @@ static StackStore stackStore;
 typedef StackDepotBase<StackDepotNode, 1, StackDepotNode::kTabSizeLog>
     StackDepot;
 static StackDepot theDepot;
-// Keep rarely accessed stack traces out of frequently access nodes to improve
-// caching efficiency.
-static TwoLevelMap<StackStore::Id, StackDepot::kNodesSize1,
-                   StackDepot::kNodesSize2>
-    storeIds;
 // Keep mutable data out of frequently access nodes to improve caching
 // efficiency.
 static TwoLevelMap<atomic_uint32_t, StackDepot::kNodesSize1,
@@ -73,17 +69,15 @@ void StackDepotHandle::inc_use_count_unsafe() {
 }
 
 uptr StackDepotNode::allocated() {
-  return stackStore.Allocated() + storeIds.MemoryUsage() +
-         useCounts.MemoryUsage();
+  return stackStore.Allocated() + useCounts.MemoryUsage();
 }
 
 void StackDepotNode::store(u32 id, const args_type &args, hash_type hash) {
   stack_hash = hash;
-  storeIds[id] = stackStore.Store(args);
+  store_id = stackStore.Store(args);
 }
 
 StackDepotNode::args_type StackDepotNode::load(u32 id) const {
-  StackStore::Id store_id = storeIds[id];
   if (!store_id)
     return {};
   return stackStore.Load(store_id);
@@ -121,7 +115,6 @@ StackDepotHandle StackDepotNode::get_handle(u32 id) {
 
 void StackDepotTestOnlyUnmap() {
   theDepot.TestOnlyUnmap();
-  storeIds.TestOnlyUnmap();
   stackStore.TestOnlyUnmap();
 }
 


        


More information about the llvm-commits mailing list