[llvm] 8ac6a6b - Reorder fields so InitDeferredFlag is destroyed last

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 09:35:23 PST 2025


Author: Benjamin Kramer
Date: 2025-01-09T18:33:42+01:00
New Revision: 8ac6a6b81629840d2456e32ec4651440523718dc

URL: https://github.com/llvm/llvm-project/commit/8ac6a6b81629840d2456e32ec4651440523718dc
DIFF: https://github.com/llvm/llvm-project/commit/8ac6a6b81629840d2456e32ec4651440523718dc.diff

LOG: Reorder fields so InitDeferredFlag is destroyed last

TimerGroup's dtor accesses this field.

once_flag has a trivial destructor so it doesn't really matter, but msan
checks that it's not accessed after destruction.

Added: 
    

Modified: 
    llvm/lib/Support/Timer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp
index ccd78ad86e91c9..3f0926ae0f3cbe 100644
--- a/llvm/lib/Support/Timer.cpp
+++ b/llvm/lib/Support/Timer.cpp
@@ -507,11 +507,11 @@ class llvm::TimerGlobals {
   // Order of these members and initialization below is important. For example
   // the DefaultTimerGroup uses the TimerLock. Most of these also depend on the
   // options above.
+  std::once_flag InitDeferredFlag;
   std::unique_ptr<SignpostEmitter> SignpostsPtr;
   std::unique_ptr<sys::SmartMutex<true>> TimerLockPtr;
   std::unique_ptr<TimerGroup> DefaultTimerGroupPtr;
   std::unique_ptr<Name2PairMap> NamedGroupedTimersPtr;
-  std::once_flag InitDeferredFlag;
   TimerGlobals &initDeferred() {
     std::call_once(InitDeferredFlag, [this]() {
       SignpostsPtr = std::make_unique<SignpostEmitter>();


        


More information about the llvm-commits mailing list