[compiler-rt] 4e1b55a - [NFC][asan] Split AsanThread::ThreadStart
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 12:48:16 PDT 2023
Author: Vitaly Buka
Date: 2023-07-26T12:48:01-07:00
New Revision: 4e1b55a781946303202fdf412acb4f151f0474d0
URL: https://github.com/llvm/llvm-project/commit/4e1b55a781946303202fdf412acb4f151f0474d0
DIFF: https://github.com/llvm/llvm-project/commit/4e1b55a781946303202fdf412acb4f151f0474d0.diff
LOG: [NFC][asan] Split AsanThread::ThreadStart
Reviewed By: kstoimenov
Differential Revision: https://reviews.llvm.org/D156290
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_thread.cpp
compiler-rt/lib/asan/asan_thread.h
compiler-rt/lib/asan/asan_win.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index b9b82564b33035..b8479038c4b2df 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -222,7 +222,8 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
SetCurrentThread(t);
auto self = GetThreadSelf();
auto args = asanThreadArgRetval().GetArgs(self);
- thread_return_t retval = t->ThreadStart(GetTid());
+ t->ThreadStart(GetTid());
+ thread_return_t retval = t->RunThread();
asanThreadArgRetval().Finish(self, retval);
CHECK_EQ(args.arg_retval, t->get_arg());
return retval;
diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp
index ba0ddddc338c4f..91d5ed74ddd1dc 100644
--- a/compiler-rt/lib/asan/asan_thread.cpp
+++ b/compiler-rt/lib/asan/asan_thread.cpp
@@ -273,24 +273,16 @@ void AsanThread::Init(const InitOptions *options) {
// asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls.
#if !SANITIZER_FUCHSIA
-thread_return_t AsanThread::ThreadStart(tid_t os_id) {
+void AsanThread::ThreadStart(tid_t os_id) {
Init();
asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr);
if (common_flags()->use_sigaltstack)
SetAlternateSignalStack();
-
- if (!start_routine_) {
- // start_routine_ == 0 if we're on the main thread or on one of the
- // OS X libdispatch worker threads. But nobody is supposed to call
- // ThreadStart() for the worker threads.
- CHECK_EQ(tid(), 0);
- return 0;
- }
-
- return start_routine_(arg_);
}
+thread_return_t AsanThread::RunThread() { return start_routine_(arg_); }
+
AsanThread *CreateMainThread() {
AsanThread *main_thread = AsanThread::Create(
/* start_routine */ nullptr, /* arg */ nullptr, /* parent_tid */ kMainTid,
diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h
index c131dd40d86471..3b31777ace6ed1 100644
--- a/compiler-rt/lib/asan/asan_thread.h
+++ b/compiler-rt/lib/asan/asan_thread.h
@@ -67,7 +67,8 @@ class AsanThread {
struct InitOptions;
void Init(const InitOptions *options = nullptr);
- thread_return_t ThreadStart(tid_t os_id);
+ void ThreadStart(tid_t os_id);
+ thread_return_t RunThread();
uptr stack_top();
uptr stack_bottom();
diff --git a/compiler-rt/lib/asan/asan_win.cpp b/compiler-rt/lib/asan/asan_win.cpp
index 82661b1a7c87d8..85e80accba63b0 100644
--- a/compiler-rt/lib/asan/asan_win.cpp
+++ b/compiler-rt/lib/asan/asan_win.cpp
@@ -134,7 +134,8 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
AsanThread *t = (AsanThread *)arg;
SetCurrentThread(t);
- auto res = t->ThreadStart(GetTid());
+ t->ThreadStart(GetTid());
+ auto res = t->RunThread();
t->Destroy(); // POSIX calls this from TSD destructor.
return res;
}
More information about the llvm-commits
mailing list