diff --git a/llvm/include/llvm/Support/Timer.h b/llvm/include/llvm/Support/Timer.h index 198855ae0377..41f1b81a8049 100644 --- a/llvm/include/llvm/Support/Timer.h +++ b/llvm/include/llvm/Support/Timer.h @@ -207,6 +207,8 @@ public: /// This static method prints all timers and clears them all out. static void printAll(raw_ostream &OS); + const char *printJSONValues(raw_ostream &OS, const char *delim); + /// Prints all timers as JSON key/value pairs, and clears them all out. static const char *printAllJSONValues(raw_ostream &OS, const char *delim); @@ -223,7 +225,6 @@ private: void PrintQueuedTimers(raw_ostream &OS); void printJSONValue(raw_ostream &OS, const PrintRecord &R, const char *suffix, double Value); - const char *printJSONValues(raw_ostream &OS, const char *delim); }; } // end namespace llvm diff --git a/llvm/lib/Support/Timer.cpp b/llvm/lib/Support/Timer.cpp index 4dbc8ed034d6..fd587fb80bbc 100644 --- a/llvm/lib/Support/Timer.cpp +++ b/llvm/lib/Support/Timer.cpp @@ -378,6 +378,8 @@ void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R, } const char *TimerGroup::printJSONValues(raw_ostream &OS, const char *delim) { + sys::SmartScopedLock L(*TimerLock); + prepareToPrintList(); for (const PrintRecord &R : TimersToPrint) { OS << delim;