@@ -163,18 +163,16 @@ bool BackendConsumer::HandleTopLevelDecl(DeclGroupRef D) {
163163 " LLVM IR generation of declaration" );
164164
165165 // Recurse.
166- if (TimerIsEnabled) {
167- LLVMIRGenerationRefCount += 1 ;
168- if (LLVMIRGenerationRefCount == 1 )
169- LLVMIRGeneration.startTimer ();
166+ if (TimerIsEnabled && !LLVMIRGenerationRefCount++) {
167+ CI.getFrontendTimer ().stopTimer ();
168+ LLVMIRGeneration.startTimer ();
170169 }
171170
172171 Gen->HandleTopLevelDecl (D);
173172
174- if (TimerIsEnabled) {
175- LLVMIRGenerationRefCount -= 1 ;
176- if (LLVMIRGenerationRefCount == 0 )
177- LLVMIRGeneration.stopTimer ();
173+ if (TimerIsEnabled && !--LLVMIRGenerationRefCount) {
174+ LLVMIRGeneration.stopTimer ();
175+ CI.getFrontendTimer ().startTimer ();
178176 }
179177
180178 return true ;
@@ -184,13 +182,17 @@ void BackendConsumer::HandleInlineFunctionDefinition(FunctionDecl *D) {
184182 PrettyStackTraceDecl CrashInfo (D, SourceLocation (),
185183 Context->getSourceManager (),
186184 " LLVM IR generation of inline function" );
187- if (TimerIsEnabled)
185+ if (TimerIsEnabled) {
186+ CI.getFrontendTimer ().stopTimer ();
188187 LLVMIRGeneration.startTimer ();
188+ }
189189
190190 Gen->HandleInlineFunctionDefinition (D);
191191
192- if (TimerIsEnabled)
192+ if (TimerIsEnabled) {
193193 LLVMIRGeneration.stopTimer ();
194+ CI.getFrontendTimer ().startTimer ();
195+ }
194196}
195197
196198void BackendConsumer::HandleInterestingDecl (DeclGroupRef D) {
@@ -240,18 +242,16 @@ void BackendConsumer::HandleTranslationUnit(ASTContext &C) {
240242 {
241243 llvm::TimeTraceScope TimeScope (" Frontend" );
242244 PrettyStackTraceString CrashInfo (" Per-file LLVM IR generation" );
243- if (TimerIsEnabled) {
244- LLVMIRGenerationRefCount += 1 ;
245- if (LLVMIRGenerationRefCount == 1 )
246- LLVMIRGeneration.startTimer ();
245+ if (TimerIsEnabled && !LLVMIRGenerationRefCount++) {
246+ CI.getFrontendTimer ().stopTimer ();
247+ LLVMIRGeneration.startTimer ();
247248 }
248249
249250 Gen->HandleTranslationUnit (C);
250251
251- if (TimerIsEnabled) {
252- LLVMIRGenerationRefCount -= 1 ;
253- if (LLVMIRGenerationRefCount == 0 )
254- LLVMIRGeneration.stopTimer ();
252+ if (TimerIsEnabled && !--LLVMIRGenerationRefCount) {
253+ LLVMIRGeneration.stopTimer ();
254+ CI.getFrontendTimer ().startTimer ();
255255 }
256256
257257 IRGenFinished = true ;
0 commit comments