https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/228640
>From 02a58c8e135bc21f15d03484c04ede345a2f794c Mon Sep 17 00:00:00 2001 From: Vitaly Buka <[email protected]> Date: Fri, 2 Oct 2026 19:51:25 -0700 Subject: [PATCH] [NFC][TSan] Merge ScopedReportBase into ScopedReport ScopedReport is the only subclass of ScopedReportBase and nothing uses ScopedReportBase directly. Merge ScopedReportBase into ScopedReport. Assisted-by: Gemini Pull Request: https://github.com/llvm/llvm-project/pull/228640 --- compiler-rt/lib/tsan/rtl/tsan_rtl.h | 23 ++++-------- compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp | 37 +++++++++----------- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index fcfbf2f445dfa..a4bf790d5980b 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -413,8 +413,11 @@ const char *GetObjectTypeFromTag(uptr tag); const char *GetReportHeaderFromTag(uptr tag); uptr TagFromShadowStackFrame(uptr pc); -class ScopedReportBase { +class ScopedReport { public: + explicit ScopedReport(ReportType typ, uptr tag = kExternalTagNone); + ~ScopedReport(); + void AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, Tid tid, StackTrace stack, const MutexSet *mset); void AddStack(StackTrace stack, bool suppressable = false); @@ -430,27 +433,15 @@ class ScopedReportBase { const ReportDesc *GetReport() const; - protected: - ScopedReportBase(ReportType typ, uptr tag); - ~ScopedReportBase(); - private: ReportDesc *rep_; // Symbolizer makes lots of intercepted calls. If we try to process them, // at best it will cause deadlocks on internal mutexes. ScopedIgnoreInterceptors ignore_interceptors_; - - ScopedReportBase(const ScopedReportBase &) = delete; - void operator=(const ScopedReportBase &) = delete; -}; - -class ScopedReport : public ScopedReportBase { - public: - explicit ScopedReport(ReportType typ, uptr tag = kExternalTagNone); - ~ScopedReport(); - - private: ScopedErrorReportLock lock_; + + ScopedReport(const ScopedReport&) = delete; + void operator=(const ScopedReport&) = delete; }; bool ShouldReport(ThreadState *thr, ReportType typ); diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp index 4a98b761b9d87..52a462617ecb4 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp @@ -163,24 +163,24 @@ bool ShouldReport(ThreadState *thr, ReportType typ) { } } -ScopedReportBase::ScopedReportBase(ReportType typ, uptr tag) { +ScopedReport::ScopedReport(ReportType typ, uptr tag) { CheckedMutex::CheckNoLocks(); rep_ = New<ReportDesc>(); rep_->typ = typ; rep_->tag = tag; } -ScopedReportBase::~ScopedReportBase() { DestroyAndFree(rep_); } +ScopedReport::~ScopedReport() { DestroyAndFree(rep_); } -void ScopedReportBase::AddStack(StackTrace stack, bool suppressable) { +void ScopedReport::AddStack(StackTrace stack, bool suppressable) { ReportStack **rs = rep_->stacks.PushBack(); *rs = SymbolizeStack(stack); (*rs)->suppressable = suppressable; } -void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, - Tid tid, StackTrace stack, - const MutexSet *mset) { +void ScopedReport::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, + Tid tid, StackTrace stack, + const MutexSet* mset) { uptr addr0, size; AccessType typ; s.GetAccess(&addr0, &size, &typ); @@ -201,7 +201,7 @@ void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, } } -void ScopedReportBase::SymbolizeStackElems() { +void ScopedReport::SymbolizeStackElems() { // symbolize memory ops for (usize i = 0, size = rep_->mops.Size(); i < size; i++) { ReportMop *mop = rep_->mops[i]; @@ -251,11 +251,11 @@ void ScopedReportBase::SymbolizeStackElems() { } } -void ScopedReportBase::AddUniqueTid(Tid unique_tid) { +void ScopedReport::AddUniqueTid(Tid unique_tid) { rep_->unique_tids.PushBack(unique_tid); } -void ScopedReportBase::AddThread(const ThreadContext *tctx, bool suppressable) { +void ScopedReport::AddThread(const ThreadContext* tctx, bool suppressable) { ctx->thread_registry.CheckLocked(); for (uptr i = 0; i < rep_->threads.Size(); i++) { if ((u32)rep_->threads[i]->id == tctx->tid) @@ -305,14 +305,14 @@ ThreadContext *IsThreadStackOrTls(uptr addr, bool *is_stack) { } #endif -void ScopedReportBase::AddThread(Tid tid, bool suppressable) { +void ScopedReport::AddThread(Tid tid, bool suppressable) { #if !SANITIZER_GO if (const ThreadContext *tctx = FindThreadByTidLocked(tid)) AddThread(tctx, suppressable); #endif } -int ScopedReportBase::AddMutex(uptr addr, StackID creation_stack_id) { +int ScopedReport::AddMutex(uptr addr, StackID creation_stack_id) { for (uptr i = 0; i < rep_->mutexes.Size(); i++) { if (rep_->mutexes[i]->addr == addr) return rep_->mutexes[i]->id; @@ -325,7 +325,7 @@ int ScopedReportBase::AddMutex(uptr addr, StackID creation_stack_id) { return rm->id; } -void ScopedReportBase::AddLocation(uptr addr, uptr size) { +void ScopedReport::AddLocation(uptr addr, uptr size) { if (addr == 0) return; #if !SANITIZER_GO @@ -380,21 +380,16 @@ void ScopedReportBase::AddLocation(uptr addr, uptr size) { } #if !SANITIZER_GO -void ScopedReportBase::AddSleep(StackID stack_id) { +void ScopedReport::AddSleep(StackID stack_id) { rep_->sleep = SymbolizeStackId(stack_id); } #endif -void ScopedReportBase::SetCount(int count) { rep_->count = count; } +void ScopedReport::SetCount(int count) { rep_->count = count; } -void ScopedReportBase::SetSigNum(int sig) { rep_->signum = sig; } +void ScopedReport::SetSigNum(int sig) { rep_->signum = sig; } -const ReportDesc *ScopedReportBase::GetReport() const { return rep_; } - -ScopedReport::ScopedReport(ReportType typ, uptr tag) - : ScopedReportBase(typ, tag) {} - -ScopedReport::~ScopedReport() {} +const ReportDesc* ScopedReport::GetReport() const { return rep_; } // Replays the trace up to last_pos position in the last part // or up to the provided epoch/sid (whichever is earlier) _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
