[compiler-rt] c4a00ed - [NFC][compiler-rt][hwasan] Move GetCurrentThread to hwasan.cpp

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 29 11:56:09 PDT 2021


Author: Leonard Chan
Date: 2021-06-29T11:55:30-07:00
New Revision: c4a00ed85192b31b1fe9c5c3e94f96f826937825

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

LOG: [NFC][compiler-rt][hwasan] Move GetCurrentThread to hwasan.cpp

We can reuse the same implementation for getting the current thread on fuchsia.

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

Added: 
    

Modified: 
    compiler-rt/lib/hwasan/hwasan.cpp
    compiler-rt/lib/hwasan/hwasan_linux.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 0401783281015..0cae96f35d35b 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -228,6 +228,14 @@ void HwasanTagMismatch(uptr addr, uptr access_info, uptr *registers_frame,
   __builtin_unreachable();
 }
 
+Thread *GetCurrentThread() {
+  uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
+  if (UNLIKELY(*ThreadLongPtr == 0))
+    return nullptr;
+  auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
+  return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
+}
+
 } // namespace __hwasan
 
 using namespace __hwasan;

diff  --git a/compiler-rt/lib/hwasan/hwasan_linux.cpp b/compiler-rt/lib/hwasan/hwasan_linux.cpp
index 12bea5ca08444..02672030886ca 100644
--- a/compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -338,14 +338,6 @@ void AndroidTestTlsSlot() {
 void AndroidTestTlsSlot() {}
 #endif
 
-Thread *GetCurrentThread() {
-  uptr *ThreadLongPtr = GetCurrentThreadLongPtr();
-  if (UNLIKELY(*ThreadLongPtr == 0))
-    return nullptr;
-  auto *R = (StackAllocationsRingBuffer *)ThreadLongPtr;
-  return hwasanThreadList().GetThreadByBufferAddress((uptr)R->Next());
-}
-
 static AccessInfo GetAccessInfo(siginfo_t *info, ucontext_t *uc) {
   // Access type is passed in a platform dependent way (see below) and encoded
   // as 0xXY, where X&1 is 1 for store, 0 for load, and X&2 is 1 if the error is


        


More information about the llvm-commits mailing list