[compiler-rt] r341432 - [hwasan] simplify the code, NFC
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 17:01:45 PDT 2018
Author: kcc
Date: Tue Sep 4 17:01:45 2018
New Revision: 341432
URL: http://llvm.org/viewvc/llvm-project?rev=341432&view=rev
Log:
[hwasan] simplify the code, NFC
Modified:
compiler-rt/trunk/lib/hwasan/hwasan.cc
compiler-rt/trunk/lib/hwasan/hwasan_linux.cc
compiler-rt/trunk/lib/hwasan/hwasan_thread.cc
compiler-rt/trunk/lib/hwasan/hwasan_thread.h
Modified: compiler-rt/trunk/lib/hwasan/hwasan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan.cc?rev=341432&r1=341431&r2=341432&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan.cc (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan.cc Tue Sep 4 17:01:45 2018
@@ -213,9 +213,7 @@ void __hwasan_init() {
HwasanAllocatorInit();
- Thread *main_thread = Thread::Create();
- SetCurrentThread(main_thread);
- main_thread->Init();
+ Thread::Create();
#if HWASAN_CONTAINS_UBSAN
__ubsan::InitAsPlugin();
Modified: compiler-rt/trunk/lib/hwasan/hwasan_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_linux.cc?rev=341432&r1=341431&r2=341432&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_linux.cc (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_linux.cc Tue Sep 4 17:01:45 2018
@@ -214,9 +214,7 @@ void InstallAtExitHandler() {
// ---------------------- TSD ---------------- {{{1
extern "C" void __hwasan_thread_enter() {
- Thread *t = Thread::Create();
- SetCurrentThread(t);
- t->Init();
+ Thread::Create();
}
extern "C" void __hwasan_thread_exit() {
Modified: compiler-rt/trunk/lib/hwasan/hwasan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_thread.cc?rev=341432&r1=341431&r2=341432&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_thread.cc (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_thread.cc Tue Sep 4 17:01:45 2018
@@ -57,7 +57,7 @@ void Thread::RemoveFromThreadList(Thread
CHECK(0 && "RemoveFromThreadList: thread not found");
}
-Thread *Thread::Create() {
+void Thread::Create() {
static u64 unique_id;
uptr PageSize = GetPageSizeCached();
uptr size = RoundUpTo(sizeof(Thread), PageSize);
@@ -68,10 +68,11 @@ Thread *Thread::Create() {
thread->heap_allocations_ = RingBuffer<HeapAllocationRecord>::New(sz);
thread->unique_id_ = unique_id++;
InsertIntoThreadList(thread);
- return thread;
+ SetCurrentThread(thread);
+ thread->Init();
}
-void Thread::SetThreadStackAndTls() {
+void Thread::Init() {
// GetPthreadDestructorIterations may call malloc, so disable the tagging.
ScopedTaggingDisabler disabler;
@@ -93,10 +94,7 @@ void Thread::SetThreadStackAndTls() {
CHECK(AddrIsInStack((uptr)&local));
CHECK(MemIsApp(stack_bottom_));
CHECK(MemIsApp(stack_top_ - 1));
-}
-void Thread::Init() {
- SetThreadStackAndTls();
if (stack_bottom_) {
CHECK(MemIsApp(stack_bottom_));
CHECK(MemIsApp(stack_top_ - 1));
Modified: compiler-rt/trunk/lib/hwasan/hwasan_thread.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_thread.h?rev=341432&r1=341431&r2=341432&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_thread.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_thread.h Tue Sep 4 17:01:45 2018
@@ -26,11 +26,9 @@ struct ThreadStartArg {
class Thread {
public:
- static Thread *Create();
+ static void Create(); // Must be called from the thread itself.
void Destroy();
- void Init();
-
uptr stack_top() { return stack_top_; }
uptr stack_bottom() { return stack_bottom_; }
uptr tls_begin() { return tls_begin_; }
@@ -82,7 +80,7 @@ class Thread {
private:
// NOTE: There is no Thread constructor. It is allocated
// via mmap() and *must* be valid in zero-initialized state.
- void SetThreadStackAndTls();
+ void Init();
void ClearShadowForThreadStackAndTLS();
void Print(const char *prefix);
uptr stack_top_;
More information about the llvm-commits
mailing list