[compiler-rt] 99a93c3 - [NFC][Asan] Rename internal enum value.

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 18:56:45 PDT 2020


Author: Vitaly Buka
Date: 2020-09-03T18:54:52-07:00
New Revision: 99a93c3a223e3bfc9a9781bfbf98d2fd4551f923

URL: https://github.com/llvm/llvm-project/commit/99a93c3a223e3bfc9a9781bfbf98d2fd4551f923
DIFF: https://github.com/llvm/llvm-project/commit/99a93c3a223e3bfc9a9781bfbf98d2fd4551f923.diff

LOG: [NFC][Asan] Rename internal enum value.

New name better represents the state of chunk.

Added: 
    

Modified: 
    compiler-rt/lib/asan/asan_allocator.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index 16b264080b5a..c7c9d7a7b3ce 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -106,8 +106,11 @@ COMPILER_CHECK(kChunkHeader2Size <= 16);
 // CHUNK_ALLOCATED: the chunk is allocated and not yet freed.
 // CHUNK_QUARANTINE: the chunk was freed and put into quarantine zone.
 enum {
-  CHUNK_AVAILABLE  = 0,  // 0 is the default value even if we didn't set it.
-  CHUNK_ALLOCATED  = 2,
+  // Either just allocated by underlying allocator, but AsanChunk is not yet
+  // ready, or almost returned to undelying allocator and AsanChunk is already
+  // meaningless.
+  CHUNK_INVALID = 0,
+  CHUNK_ALLOCATED = 2,
   CHUNK_QUARANTINE = 3
 };
 
@@ -142,8 +145,7 @@ struct QuarantineCallback {
   void Recycle(AsanChunk *m) {
     u8 old_chunk_state = CHUNK_QUARANTINE;
     if (!atomic_compare_exchange_strong(&m->chunk_state, &old_chunk_state,
-                                        CHUNK_AVAILABLE,
-                                        memory_order_acquire)) {
+                                        CHUNK_INVALID, memory_order_acquire)) {
       CHECK_EQ(old_chunk_state, CHUNK_QUARANTINE);
     }
 
@@ -859,7 +861,7 @@ static AsanAllocator &get_allocator() {
 
 bool AsanChunkView::IsValid() const {
   return chunk_ && atomic_load(&chunk_->chunk_state, memory_order_relaxed) !=
-                       CHUNK_AVAILABLE;
+                       CHUNK_INVALID;
 }
 bool AsanChunkView::IsAllocated() const {
   return chunk_ && atomic_load(&chunk_->chunk_state, memory_order_relaxed) ==


        


More information about the llvm-commits mailing list