diff --git a/compiler-rt/lib/tsan/go/tsan_go.cpp b/compiler-rt/lib/tsan/go/tsan_go.cpp --- a/compiler-rt/lib/tsan/go/tsan_go.cpp +++ b/compiler-rt/lib/tsan/go/tsan_go.cpp @@ -27,9 +27,7 @@ return false; } -void *internal_alloc(MBlockType typ, uptr sz) { - return InternalAlloc(sz); -} +void *internal_alloc(uptr sz) { return InternalAlloc(sz); } void internal_free(void *p) { InternalFree(p); @@ -142,8 +140,7 @@ extern "C" { static ThreadState *AllocGoroutine() { - ThreadState *thr = (ThreadState*)internal_alloc(MBlockThreadContex, - sizeof(ThreadState)); + ThreadState *thr = (ThreadState *)internal_alloc(sizeof(ThreadState)); internal_memset(thr, 0, sizeof(*thr)); return thr; } diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp @@ -90,7 +90,7 @@ return; } } - race = (ExpectRace*)internal_alloc(MBlockExpectRace, sizeof(ExpectRace)); + race = (ExpectRace *)internal_alloc(sizeof(ExpectRace)); race->addr = addr; race->size = size; race->file = f; diff --git a/compiler-rt/lib/tsan/rtl/tsan_mman.h b/compiler-rt/lib/tsan/rtl/tsan_mman.h --- a/compiler-rt/lib/tsan/rtl/tsan_mman.h +++ b/compiler-rt/lib/tsan/rtl/tsan_mman.h @@ -47,36 +47,8 @@ void invoke_malloc_hook(void *ptr, uptr size); void invoke_free_hook(void *ptr); -enum MBlockType { - MBlockScopedBuf, - MBlockString, - MBlockStackTrace, - MBlockShadowStack, - MBlockSync, - MBlockClock, - MBlockThreadContex, - MBlockDeadInfo, - MBlockRacyStacks, - MBlockRacyAddresses, - MBlockAtExit, - MBlockFlag, - MBlockReport, - MBlockReportMop, - MBlockReportThread, - MBlockReportMutex, - MBlockReportLoc, - MBlockReportStack, - MBlockSuppression, - MBlockExpectRace, - MBlockSignal, - MBlockJmpBuf, - - // This must be the last. - MBlockTypeCount -}; - // For internal data structures. -void *internal_alloc(MBlockType typ, uptr sz); +void *internal_alloc(uptr sz); void internal_free(void *p); template diff --git a/compiler-rt/lib/tsan/rtl/tsan_mman.cpp b/compiler-rt/lib/tsan/rtl/tsan_mman.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_mman.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_mman.cpp @@ -336,7 +336,7 @@ RunFreeHooks(ptr); } -void *internal_alloc(MBlockType typ, uptr sz) { +void *internal_alloc(uptr sz) { ThreadState *thr = cur_thread(); if (thr->nomalloc) { thr->nomalloc = 0; // CHECK calls internal_malloc(). diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp @@ -22,7 +22,7 @@ ReportStack::ReportStack() : frames(nullptr), suppressable(false) {} ReportStack *ReportStack::New() { - void *mem = internal_alloc(MBlockReportStack, sizeof(ReportStack)); + void *mem = internal_alloc(sizeof(ReportStack)); return new(mem) ReportStack(); } @@ -31,7 +31,7 @@ fd(0), suppressable(false), stack(nullptr) {} ReportLocation *ReportLocation::New(ReportLocationType type) { - void *mem = internal_alloc(MBlockReportStack, sizeof(ReportLocation)); + void *mem = internal_alloc(sizeof(ReportLocation)); return new(mem) ReportLocation(type); } diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -543,9 +543,6 @@ ClockAlloc clock_alloc; Flags flags; - - u64 int_alloc_cnt[MBlockTypeCount]; - u64 int_alloc_siz[MBlockTypeCount]; }; extern Context *ctx; // The one and the only global runtime context. diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp @@ -103,7 +103,7 @@ CHECK("unable to mprotect" && 0); } } - void *mem = internal_alloc(MBlockThreadContex, sizeof(ThreadContext)); + void *mem = internal_alloc(sizeof(ThreadContext)); return new(mem) ThreadContext(tid); } @@ -578,8 +578,7 @@ void GrowShadowStack(ThreadState *thr) { const int sz = thr->shadow_stack_end - thr->shadow_stack; const int newsz = 2 * sz; - uptr *newstack = (uptr*)internal_alloc(MBlockShadowStack, - newsz * sizeof(uptr)); + uptr *newstack = (uptr *)internal_alloc(newsz * sizeof(uptr)); internal_memcpy(newstack, thr->shadow_stack, sz * sizeof(uptr)); internal_free(thr->shadow_stack); thr->shadow_stack = newstack; diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp @@ -155,7 +155,7 @@ ScopedReportBase::ScopedReportBase(ReportType typ, uptr tag) { ctx->thread_registry->CheckLocked(); - void *mem = internal_alloc(MBlockReport, sizeof(ReportDesc)); + void *mem = internal_alloc(sizeof(ReportDesc)); rep_ = new(mem) ReportDesc; rep_->typ = typ; rep_->tag = tag; @@ -176,7 +176,7 @@ void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, StackTrace stack, const MutexSet *mset) { - void *mem = internal_alloc(MBlockReportMop, sizeof(ReportMop)); + void *mem = internal_alloc(sizeof(ReportMop)); ReportMop *mop = new(mem) ReportMop; rep_->mops.PushBack(mop); mop->tid = s.tid(); @@ -205,7 +205,7 @@ if ((u32)rep_->threads[i]->id == tctx->tid) return; } - void *mem = internal_alloc(MBlockReportThread, sizeof(ReportThread)); + void *mem = internal_alloc(sizeof(ReportThread)); ReportThread *rt = new(mem) ReportThread; rep_->threads.PushBack(rt); rt->id = tctx->tid; @@ -276,7 +276,7 @@ if (rep_->mutexes[i]->id == s->uid) return; } - void *mem = internal_alloc(MBlockReportMutex, sizeof(ReportMutex)); + void *mem = internal_alloc(sizeof(ReportMutex)); ReportMutex *rm = new(mem) ReportMutex; rep_->mutexes.PushBack(rm); rm->id = s->uid; @@ -309,7 +309,7 @@ if (rep_->mutexes[i]->id == id) return; } - void *mem = internal_alloc(MBlockReportMutex, sizeof(ReportMutex)); + void *mem = internal_alloc(sizeof(ReportMutex)); ReportMutex *rm = new(mem) ReportMutex; rep_->mutexes.PushBack(rm); rm->id = id; @@ -739,8 +739,7 @@ #if !SANITIZER_GO uptr bp = GET_CURRENT_FRAME(); BufferedStackTrace *ptrace = - new(internal_alloc(MBlockStackTrace, sizeof(BufferedStackTrace))) - BufferedStackTrace(); + new (internal_alloc(sizeof(BufferedStackTrace))) BufferedStackTrace(); ptrace->Unwind(pc, bp, nullptr, false); for (uptr i = 0; i < ptrace->size / 2; i++) { diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp @@ -99,8 +99,7 @@ #else // Setup dynamic shadow stack. const int kInitStackSize = 8; - thr->shadow_stack = (uptr*)internal_alloc(MBlockShadowStack, - kInitStackSize * sizeof(uptr)); + thr->shadow_stack = (uptr *)internal_alloc(kInitStackSize * sizeof(uptr)); thr->shadow_stack_pos = thr->shadow_stack; thr->shadow_stack_end = thr->shadow_stack + kInitStackSize; #endif @@ -421,7 +420,7 @@ } ThreadState *FiberCreate(ThreadState *thr, uptr pc, unsigned flags) { - void *mem = internal_alloc(MBlockThreadContex, sizeof(ThreadState)); + void *mem = internal_alloc(sizeof(ThreadState)); ThreadState *fiber = static_cast(mem); internal_memset(fiber, 0, sizeof(*fiber)); int tid = ThreadCreate(thr, pc, 0, true); diff --git a/compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp b/compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_stack_trace.cpp @@ -28,8 +28,7 @@ } trace_buffer = (new_size > 0) - ? (uptr *)internal_alloc(MBlockStackTrace, - new_size * sizeof(trace_buffer[0])) + ? (uptr *)internal_alloc(new_size * sizeof(trace_buffer[0])) : nullptr; trace = trace_buffer; size = new_size; diff --git a/compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cpp b/compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cpp --- a/compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cpp +++ b/compiler-rt/lib/tsan/tests/unit/tsan_mman_test.cpp @@ -18,9 +18,9 @@ namespace __tsan { TEST(Mman, Internal) { - char *p = (char*)internal_alloc(MBlockScopedBuf, 10); + char *p = (char *)internal_alloc(10); EXPECT_NE(p, (char*)0); - char *p2 = (char*)internal_alloc(MBlockScopedBuf, 20); + char *p2 = (char *)internal_alloc(20); EXPECT_NE(p2, (char*)0); EXPECT_NE(p2, p); for (int i = 0; i < 10; i++) {