================ @@ -38,63 +38,40 @@ using namespace llvm; -// This ugly hack is brought to you courtesy of constructor/destructor ordering -// being unspecified by C++. Basically the problem is that a Statistic object -// gets destroyed, which ends up calling 'GetLibSupportInfoOutputFile()' -// (below), which calls this function. LibSupportInfoOutputFilename used to be -// a global variable, but sometimes it would get destroyed before the Statistic, -// causing havoc to ensue. We "fix" this by creating the string the first time -// it is needed and never destroying it. -static ManagedStatic<std::string> LibSupportInfoOutputFilename; -static std::string &getLibSupportInfoOutputFilename() { - return *LibSupportInfoOutputFilename; +//===----------------------------------------------------------------------===// +// Forward declarations for Managed Timer Globals (mtg) getters. +// +// Globals have been placed at the end of the file to restrict direct +// access. Use of getters also has the benefit of making it a bit more explicit +// that a global is being used. +//===----------------------------------------------------------------------===// +namespace { +class Name2PairMap; } -static ManagedStatic<sys::SmartMutex<true> > TimerLock; - -/// Allows llvm::Timer to emit signposts when supported. -static ManagedStatic<SignpostEmitter> Signposts; - -namespace { -struct CreateTrackSpace { - static void *call() { - return new cl::opt<bool>("track-memory", - cl::desc("Enable -time-passes memory " - "tracking (this may be slow)"), - cl::Hidden); - } -}; -static ManagedStatic<cl::opt<bool>, CreateTrackSpace> TrackSpace; -struct CreateInfoOutputFilename { - static void *call() { - return new cl::opt<std::string, true>( - "info-output-file", cl::value_desc("filename"), - cl::desc("File to append -stats and -timer output to"), cl::Hidden, - cl::location(getLibSupportInfoOutputFilename())); - } -}; -static ManagedStatic<cl::opt<std::string, true>, CreateInfoOutputFilename> - InfoOutputFilename; -struct CreateSortTimers { - static void *call() { - return new cl::opt<bool>( - "sort-timers", - cl::desc("In the report, sort the timers in each group " - "in wall clock time order"), - cl::init(true), cl::Hidden); - } -}; -ManagedStatic<cl::opt<bool>, CreateSortTimers> SortTimers; -} // namespace +namespace mtg { +static std::string &LibSupportInfoOutputFilename(); +static const std::string &InfoOutputFilename(); +static bool TrackSpace(); +static bool SortTimers(); +static SignpostEmitter &Signposts(); +static sys::SmartMutex<true> &TimerLock(); +static TimerGroup &DefaultTimerGroup(); +static TimerGroup *claimDefaultTimerGroup(); ---------------- macurtis-amd wrote:
Added `get` prefix to functions. https://github.com/llvm/llvm-project/pull/121663 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits