================
@@ -11003,8 +11003,9 @@ void ASTReader::diagnoseOdrViolations() {
 }
 
 void ASTReader::StartedDeserializing() {
-  if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
-    ReadTimer->startTimer();
+  if (llvm::Timer *T = ReadTimer.get();
+      ++NumCurrentElementsDeserializing == 1 && T && !T->isRunning())
+    T->startTimer();
----------------
ilya-biryukov wrote:

Timer is a red flag, but the problem goes deeper and the fact that 
`FinishDeserializing` starts deserializing again and is therefore called 
recursively is really hard to wrap your head around.

Could we instead move the decrement of `NumCurrentElementsDeserializing` to the 
end of `ASTReader::FinishedDeserializing`? That would ensure not only that the 
timer is never reinitialized, but also that we never call 
`ASTReader::FinishedDeserializing` from `ASTReader::FinishedDeserializing`.

Basically, this comment from `ASTReader::FinishedDeserializing`:
```
    // We decrease NumCurrentElementsDeserializing only after pending actions
    // are finished, to avoid recursively re-calling finishPendingActions().
```
is actually applicable to the whole function.


Could you try that out and see if any tests fail?

https://github.com/llvm/llvm-project/pull/154231
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to