[compiler-rt] 884d290 - [sanitizer] Remove SpinMutexLock from stat function
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 12 13:49:18 PDT 2021
Author: Vitaly Buka
Date: 2021-10-12T13:49:10-07:00
New Revision: 884d290427e54eaf4b1123389c7b2665f86df7e3
URL: https://github.com/llvm/llvm-project/commit/884d290427e54eaf4b1123389c7b2665f86df7e3
DIFF: https://github.com/llvm/llvm-project/commit/884d290427e54eaf4b1123389c7b2665f86df7e3.diff
LOG: [sanitizer] Remove SpinMutexLock from stat function
Mapped size is more appropriate for most users.
Depends on D111605.
Reviewed By: dvyukov
Differential Revision: https://reviews.llvm.org/D111607
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
index 2c51fb46e123..b7afaccf0601 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
@@ -24,11 +24,7 @@ template <typename T>
class PersistentAllocator {
public:
T *alloc(uptr count = 1);
- uptr allocated() const {
- SpinMutexLock l(&mtx);
- return atomic_load_relaxed(&mapped_size) +
- atomic_load_relaxed(®ion_pos) - atomic_load_relaxed(®ion_end);
- }
+ uptr allocated() const { return atomic_load_relaxed(&mapped_size); }
private:
T *tryAlloc(uptr count);
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
index f4951c677f90..8e3021f61377 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp
@@ -81,10 +81,12 @@ TEST(SanitizerCommon, ChainedOriginDepotStats) {
EXPECT_EQ(stats2.n_uniq_ids, stats1.n_uniq_ids);
EXPECT_EQ(stats2.allocated, stats1.allocated);
- EXPECT_TRUE(chainedOriginDepot.Put(35, 36, &new_id));
- StackDepotStats stats3 = chainedOriginDepot.GetStats();
- EXPECT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1);
- EXPECT_GT(stats3.allocated, stats2.allocated);
+ for (int i = 0; i < 100000; ++i) {
+ ASSERT_TRUE(chainedOriginDepot.Put(35, i, &new_id));
+ StackDepotStats stats3 = chainedOriginDepot.GetStats();
+ ASSERT_EQ(stats3.n_uniq_ids, stats2.n_uniq_ids + 1 + i);
+ }
+ EXPECT_GT(chainedOriginDepot.GetStats().allocated, stats2.allocated);
}
} // namespace __sanitizer
More information about the llvm-commits
mailing list