Skip to content

Commit 4e1b55a

Browse files
committed
[NFC][asan] Split AsanThread::ThreadStart
Reviewed By: kstoimenov Differential Revision: https://reviews.llvm.org/D156290
1 parent 011cc6d commit 4e1b55a

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

compiler-rt/lib/asan/asan_interceptors.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
222222
SetCurrentThread(t);
223223
auto self = GetThreadSelf();
224224
auto args = asanThreadArgRetval().GetArgs(self);
225-
thread_return_t retval = t->ThreadStart(GetTid());
225+
t->ThreadStart(GetTid());
226+
thread_return_t retval = t->RunThread();
226227
asanThreadArgRetval().Finish(self, retval);
227228
CHECK_EQ(args.arg_retval, t->get_arg());
228229
return retval;

compiler-rt/lib/asan/asan_thread.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,24 +273,16 @@ void AsanThread::Init(const InitOptions *options) {
273273
// asan_fuchsia.c definies CreateMainThread and SetThreadStackAndTls.
274274
#if !SANITIZER_FUCHSIA
275275

276-
thread_return_t AsanThread::ThreadStart(tid_t os_id) {
276+
void AsanThread::ThreadStart(tid_t os_id) {
277277
Init();
278278
asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr);
279279

280280
if (common_flags()->use_sigaltstack)
281281
SetAlternateSignalStack();
282-
283-
if (!start_routine_) {
284-
// start_routine_ == 0 if we're on the main thread or on one of the
285-
// OS X libdispatch worker threads. But nobody is supposed to call
286-
// ThreadStart() for the worker threads.
287-
CHECK_EQ(tid(), 0);
288-
return 0;
289-
}
290-
291-
return start_routine_(arg_);
292282
}
293283

284+
thread_return_t AsanThread::RunThread() { return start_routine_(arg_); }
285+
294286
AsanThread *CreateMainThread() {
295287
AsanThread *main_thread = AsanThread::Create(
296288
/* start_routine */ nullptr, /* arg */ nullptr, /* parent_tid */ kMainTid,

compiler-rt/lib/asan/asan_thread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class AsanThread {
6767
struct InitOptions;
6868
void Init(const InitOptions *options = nullptr);
6969

70-
thread_return_t ThreadStart(tid_t os_id);
70+
void ThreadStart(tid_t os_id);
71+
thread_return_t RunThread();
7172

7273
uptr stack_top();
7374
uptr stack_bottom();

compiler-rt/lib/asan/asan_win.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
134134
static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
135135
AsanThread *t = (AsanThread *)arg;
136136
SetCurrentThread(t);
137-
auto res = t->ThreadStart(GetTid());
137+
t->ThreadStart(GetTid());
138+
auto res = t->RunThread();
138139
t->Destroy(); // POSIX calls this from TSD destructor.
139140
return res;
140141
}

0 commit comments

Comments
 (0)