[compiler-rt] f031fc3 - [NFC][HWASAN] Switch to verbose CHECKs

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 14:19:34 PDT 2023


Author: Vitaly Buka
Date: 2023-05-04T14:19:19-07:00
New Revision: f031fc35716cd48c7b1eb32604dbba45d99c5fef

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

LOG: [NFC][HWASAN] Switch to verbose CHECKs

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan.cpp
    compiler-rt/lib/hwasan/hwasan_linux.cpp
    compiler-rt/lib/hwasan/hwasan_report.cpp
    compiler-rt/lib/hwasan/hwasan_thread_list.cpp
    compiler-rt/lib/hwasan/hwasan_thread_list.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 26aae9b4869b9..238fcc4d61853 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -579,7 +579,7 @@ uptr __hwasan_tag_pointer(uptr p, u8 tag) {
 void __hwasan_handle_longjmp(const void *sp_dst) {
   uptr dst = (uptr)sp_dst;
   // HWASan does not support tagged SP.
-  CHECK(GetTagFromPointer(dst) == 0);
+  CHECK_EQ(GetTagFromPointer(dst), 0);
 
   uptr sp = (uptr)__builtin_frame_address(0);
   static const uptr kMaxExpectedCleanupSize = 64 << 20;  // 64M

diff  --git a/compiler-rt/lib/hwasan/hwasan_linux.cpp b/compiler-rt/lib/hwasan/hwasan_linux.cpp
index d3e4b5390e827..abf92d290c846 100644
--- a/compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -283,7 +283,7 @@ void InitThreads() {
 bool MemIsApp(uptr p) {
 // Memory outside the alias range has non-zero tags.
 #  if !defined(HWASAN_ALIASING_MODE)
-  CHECK(GetTagFromPointer(p) == 0);
+  CHECK_EQ(GetTagFromPointer(p), 0);
 #  endif
 
   return (p >= kHighMemStart && p <= kHighMemEnd) ||

diff  --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 8f9dc6cf13e04..935bae3e7bf79 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -707,7 +707,8 @@ void ReportTagMismatch(StackTrace *stack, uptr tagged_addr, uptr access_size,
 
   sptr offset =
       __hwasan_test_shadow(reinterpret_cast<void *>(tagged_addr), access_size);
-  CHECK(offset >= 0 && offset < static_cast<sptr>(access_size));
+  CHECK_GE(offset, 0);
+  CHECK_LT(offset, static_cast<sptr>(access_size));
   tag_t ptr_tag = GetTagFromPointer(tagged_addr);
   tag_t *tag_ptr =
       reinterpret_cast<tag_t *>(MemToShadow(untagged_addr + offset));

diff  --git a/compiler-rt/lib/hwasan/hwasan_thread_list.cpp b/compiler-rt/lib/hwasan/hwasan_thread_list.cpp
index fa46e658b69d5..d528f520cc9eb 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread_list.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_thread_list.cpp
@@ -7,7 +7,7 @@ static HwasanThreadList *hwasan_thread_list;
 HwasanThreadList &hwasanThreadList() { return *hwasan_thread_list; }
 
 void InitThreadList(uptr storage, uptr size) {
-  CHECK(hwasan_thread_list == nullptr);
+  CHECK_EQ(hwasan_thread_list, nullptr);
   hwasan_thread_list =
       new (thread_list_placeholder) HwasanThreadList(storage, size);
 }

diff  --git a/compiler-rt/lib/hwasan/hwasan_thread_list.h b/compiler-rt/lib/hwasan/hwasan_thread_list.h
index 97485b195b64e..99d2d460261fc 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread_list.h
+++ b/compiler-rt/lib/hwasan/hwasan_thread_list.h
@@ -199,7 +199,7 @@ class SANITIZER_MUTEX HwasanThreadList {
     CHECK(IsAligned(free_space_, align));
     Thread *t = (Thread *)(free_space_ + ring_buffer_size_);
     free_space_ += thread_alloc_size_;
-    CHECK(free_space_ <= free_space_end_ && "out of thread memory");
+    CHECK_LE(free_space_, free_space_end_);
     return t;
   }
 


        


More information about the llvm-commits mailing list