printing statistics timers


The code in Support/Timer.cpp has strangely inconsistent behavior for printAll vs printJSONValues.
The former can work multiple times, while the latter calls prepareToPrintList(), which stops all timers,
hence making all further attempts to print timers crash.

Would it be possible not to call prepareToPrintList on printJSONValues, or at least make it optional?
I am trying to serialize displayed statistic using PrintStatisticJSON, and it actually crashes if the statistic is printed again
due to stopped timers.


The diff which I’ve ended up using to do what I need is:

diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index 0c85faecca8..7fe8d776cfb 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -336,10 +336,16 @@ void TimerGroup::prepareToPrintList() {
   // reset them.
   for (Timer *T = FirstTimer; T; T = T->Next) {
     if (!T->hasTriggered()) continue;