[compiler-rt] 9e68b7e - [NFC][sanitizer] Rename internal getters

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 21:05:47 PDT 2023


Author: Vitaly Buka
Date: 2023-06-21T21:05:27-07:00
New Revision: 9e68b7e0e04f89cd3810102016ddf34fd3a33b3d

URL: https://github.com/llvm/llvm-project/commit/9e68b7e0e04f89cd3810102016ddf34fd3a33b3d
DIFF: https://github.com/llvm/llvm-project/commit/9e68b7e0e04f89cd3810102016ddf34fd3a33b3d.diff

LOG: [NFC][sanitizer] Rename internal getters

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_allocator.cpp
    compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index b994c7ecc27d1..57c15cfb6b2fb 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -397,8 +397,9 @@ struct Allocator {
   }
 
   void GetOptions(AllocatorOptions *options) const {
-    options->quarantine_size_mb = quarantine.GetSize() >> 20;
-    options->thread_local_quarantine_size_kb = quarantine.GetCacheSize() >> 10;
+    options->quarantine_size_mb = quarantine.GetMaxSize() >> 20;
+    options->thread_local_quarantine_size_kb =
+        quarantine.GetMaxCacheSize() >> 10;
     options->min_redzone = atomic_load(&min_redzone, memory_order_acquire);
     options->max_redzone = atomic_load(&max_redzone, memory_order_acquire);
     options->may_return_null = AllocatorMayReturnNull();

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
index 4aa6054851666..0665db535cce3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
@@ -94,21 +94,19 @@ class Quarantine {
     recycle_mutex_.Init();
   }
 
-  uptr GetSize() const { return atomic_load_relaxed(&max_size_); }
-  uptr GetCacheSize() const {
-    return atomic_load_relaxed(&max_cache_size_);
-  }
+  uptr GetMaxSize() const { return atomic_load_relaxed(&max_size_); }
+  uptr GetMaxCacheSize() const { return atomic_load_relaxed(&max_cache_size_); }
 
   void Put(Cache *c, Callback cb, Node *ptr, uptr size) {
-    uptr cache_size = GetCacheSize();
-    if (cache_size) {
+    uptr max_cache_size = GetMaxCacheSize();
+    if (max_cache_size) {
       c->Enqueue(cb, ptr, size);
     } else {
-      // GetCacheSize() == 0 only when GetSize() == 0 (see Init).
+      // GetMaxCacheSize() == 0 only when GetMaxSize() == 0 (see Init).
       cb.Recycle(ptr);
     }
     // Check cache size anyway to accommodate for runtime cache_size change.
-    if (c->Size() > cache_size)
+    if (c->Size() > max_cache_size)
       Drain(c, cb);
   }
 
@@ -117,7 +115,7 @@ class Quarantine {
       SpinMutexLock l(&cache_mutex_);
       cache_.Transfer(c);
     }
-    if (cache_.Size() > GetSize() && recycle_mutex_.TryLock())
+    if (cache_.Size() > GetMaxSize() && recycle_mutex_.TryLock())
       Recycle(atomic_load_relaxed(&min_size_), cb);
   }
 
@@ -133,7 +131,7 @@ class Quarantine {
   void PrintStats() const {
     // It assumes that the world is stopped, just as the allocator's PrintStats.
     Printf("Quarantine limits: global: %zdMb; thread local: %zdKb\n",
-           GetSize() >> 20, GetCacheSize() >> 10);
+           GetMaxSize() >> 20, GetMaxCacheSize() >> 10);
     cache_.PrintStats();
   }
 


        


More information about the llvm-commits mailing list