[compiler-rt] [scudo] Add ScopedTSD to avoid releasing TSD manually (PR #80061)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 14:11:03 PST 2024
================
@@ -27,6 +27,31 @@ struct ThreadState {
template <class Allocator> void teardownThread(void *Ptr);
template <class Allocator> struct TSDRegistryExT {
+ using ThisT = TSDRegistryExT<Allocator>;
+
+ struct ScopedTSD {
+ ScopedTSD(ThisT &TSDRegistry) {
+ CurrentTSD = TSDRegistry.getTSDAndLock(&IsFallback);
+ DCHECK_NE(CurrentTSD, nullptr);
+ }
+
+ ~ScopedTSD() {
+ if (UNLIKELY(IsFallback))
----------------
ChiaHungDuan wrote:
You're right, that does look better. Done.
https://github.com/llvm/llvm-project/pull/80061
More information about the llvm-commits
mailing list