[PATCH] D47502: [asan, myriad] Simplify main thread handling
Walter Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 22:01:35 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333504: [asan, myriad] Simplify main thread handling (authored by waltl, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D47502?vs=148993&id=149042#toc
Repository:
rL LLVM
https://reviews.llvm.org/D47502
Files:
compiler-rt/trunk/lib/asan/asan_rtems.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.h
Index: compiler-rt/trunk/lib/asan/asan_rtems.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_rtems.cc
+++ compiler-rt/trunk/lib/asan/asan_rtems.cc
@@ -72,11 +72,6 @@
ResetShadowMemory();
}
-// Main thread information. Initialized in CreateMainThread() and
-// used by ThreadStartHook().
-static uptr MainThreadSelf;
-static AsanThread *MainThread;
-
// We can use a plain thread_local variable for TSD.
static thread_local void *per_thread;
@@ -134,18 +129,12 @@
tls_end_ = options->tls_bottom + options->tls_size;
}
-// Called by __asan::AsanInitInternal (asan_rtl.c).
+// Called by __asan::AsanInitInternal (asan_rtl.c). Unlike other ports, the
+// main thread on RTEMS does not require special treatment; its AsanThread is
+// already created by the provided hooks. This function simply looks up and
+// returns the created thread.
AsanThread *CreateMainThread() {
- CHECK_NE(__sanitizer::MainThreadStackBase, 0);
- CHECK_GT(__sanitizer::MainThreadStackSize, 0);
- AsanThread *t = CreateAsanThread(
- nullptr, 0, GetThreadSelf(), true,
- __sanitizer::MainThreadStackBase, __sanitizer::MainThreadStackSize,
- __sanitizer::MainThreadTlsBase, __sanitizer::MainThreadTlsSize);
- SetCurrentThread(t);
- MainThreadSelf = pthread_self();
- MainThread = t;
- return t;
+ return GetThreadContextByTidLocked(0)->thread;
}
// This is called before each thread creation is attempted. So, in
@@ -179,16 +168,14 @@
}
}
-// This is called (1) in the newly-created thread before it runs
-// anything else, with the pointer returned by BeforeThreadCreateHook
-// (above). cf. asan_interceptors.cc:asan_thread_start. (2) before
-// a thread restart.
+// This is called (1) in the newly-created thread before it runs anything else,
+// with the pointer returned by BeforeThreadCreateHook (above). (2) before a
+// thread restart.
static void ThreadStartHook(void *hook, uptr os_id) {
- if (!hook && !MainThreadSelf)
+ if (!hook)
return;
- DCHECK(hook || os_id == MainThreadSelf);
- AsanThread *thread = hook ? static_cast<AsanThread *>(hook) : MainThread;
+ AsanThread *thread = static_cast<AsanThread *>(hook);
SetCurrentThread(thread);
ThreadStatus status =
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.cc
@@ -275,14 +275,4 @@
} // namespace __sanitizer
-extern "C" {
-void __sanitizer_startup_hook(void *stack_base, size_t stack_size,
- void *tls_base, size_t tls_size) {
- __sanitizer::MainThreadStackBase = reinterpret_cast<uintptr_t>(stack_base);
- __sanitizer::MainThreadStackSize = stack_size;
- __sanitizer::MainThreadTlsBase = reinterpret_cast<uintptr_t>(tls_base);
- __sanitizer::MainThreadTlsSize = tls_size;
-}
-} // extern "C"
-
#endif // SANITIZER_RTEMS
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_rtems.h
@@ -17,12 +17,5 @@
#if SANITIZER_RTEMS
#include "sanitizer_common.h"
-namespace __sanitizer {
-
-extern uptr MainThreadStackBase, MainThreadStackSize;
-extern uptr MainThreadTlsBase, MainThreadTlsSize;
-
-} // namespace __sanitizer
-
#endif // SANITIZER_RTEMS
#endif // SANITIZER_RTEMS_H
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47502.149042.patch
Type: text/x-patch
Size: 3591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180530/32dfd723/attachment.bin>
More information about the llvm-commits
mailing list