@@ -196,7 +196,9 @@ class AnalysisConsumer : public AnalysisASTConsumer,
196
196
197
197
// / Time the analyzes time of each translation unit.
198
198
std::unique_ptr<llvm::TimerGroup> AnalyzerTimers;
199
- std::unique_ptr<llvm::Timer> TUTotalTimer;
199
+ std::unique_ptr<llvm::Timer> SyntaxCheckTimer;
200
+ std::unique_ptr<llvm::Timer> ExprEngineTimer;
201
+ std::unique_ptr<llvm::Timer> BugReporterTimer;
200
202
201
203
// / The information about analyzed functions shared throughout the
202
204
// / translation unit.
@@ -212,8 +214,13 @@ class AnalysisConsumer : public AnalysisASTConsumer,
212
214
if (Opts->PrintStats || Opts->ShouldSerializeStats ) {
213
215
AnalyzerTimers = llvm::make_unique<llvm::TimerGroup>(
214
216
" analyzer" , " Analyzer timers" );
215
- TUTotalTimer = llvm::make_unique<llvm::Timer>(
216
- " time" , " Analyzer total time" , *AnalyzerTimers);
217
+ SyntaxCheckTimer = llvm::make_unique<llvm::Timer>(
218
+ " syntaxchecks" , " Syntax-based analysis time" , *AnalyzerTimers);
219
+ ExprEngineTimer = llvm::make_unique<llvm::Timer>(
220
+ " exprengine" , " Path exploration time" , *AnalyzerTimers);
221
+ BugReporterTimer = llvm::make_unique<llvm::Timer>(
222
+ " bugreporter" , " Path-sensitive report post-processing time" ,
223
+ *AnalyzerTimers);
217
224
llvm::EnableStatistics (/* PrintOnExit= */ false );
218
225
}
219
226
}
@@ -346,8 +353,13 @@ class AnalysisConsumer : public AnalysisASTConsumer,
346
353
// / Handle callbacks for arbitrary Decls.
347
354
bool VisitDecl (Decl *D) {
348
355
AnalysisMode Mode = getModeForDecl (D, RecVisitorMode);
349
- if (Mode & AM_Syntax)
356
+ if (Mode & AM_Syntax) {
357
+ if (SyntaxCheckTimer)
358
+ SyntaxCheckTimer->startTimer ();
350
359
checkerMgr->runCheckersOnASTDecl (D, *Mgr, *RecVisitorBR);
360
+ if (SyntaxCheckTimer)
361
+ SyntaxCheckTimer->stopTimer ();
362
+ }
351
363
return true ;
352
364
}
353
365
@@ -566,7 +578,11 @@ static bool isBisonFile(ASTContext &C) {
566
578
void AnalysisConsumer::runAnalysisOnTranslationUnit (ASTContext &C) {
567
579
BugReporter BR (*Mgr);
568
580
TranslationUnitDecl *TU = C.getTranslationUnitDecl ();
581
+ if (SyntaxCheckTimer)
582
+ SyntaxCheckTimer->startTimer ();
569
583
checkerMgr->runCheckersOnASTDecl (TU, *Mgr, BR);
584
+ if (SyntaxCheckTimer)
585
+ SyntaxCheckTimer->stopTimer ();
570
586
571
587
// Run the AST-only checks using the order in which functions are defined.
572
588
// If inlining is not turned on, use the simplest function order for path
@@ -608,8 +624,6 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
608
624
if (Diags.hasErrorOccurred () || Diags.hasFatalErrorOccurred ())
609
625
return ;
610
626
611
- if (TUTotalTimer) TUTotalTimer->startTimer ();
612
-
613
627
if (isBisonFile (C)) {
614
628
reportAnalyzerProgress (" Skipping bison-generated file\n " );
615
629
} else if (Opts->DisableAllChecks ) {
@@ -622,8 +636,6 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
622
636
runAnalysisOnTranslationUnit (C);
623
637
}
624
638
625
- if (TUTotalTimer) TUTotalTimer->stopTimer ();
626
-
627
639
// Count how many basic blocks we have not covered.
628
640
NumBlocksInAnalyzedFunctions = FunctionSummaries.getTotalNumBasicBlocks ();
629
641
NumVisitedBlocksInAnalyzedFunctions =
@@ -747,8 +759,13 @@ void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
747
759
748
760
BugReporter BR (*Mgr);
749
761
750
- if (Mode & AM_Syntax)
762
+ if (Mode & AM_Syntax) {
763
+ if (SyntaxCheckTimer)
764
+ SyntaxCheckTimer->startTimer ();
751
765
checkerMgr->runCheckersOnASTBody (D, *Mgr, BR);
766
+ if (SyntaxCheckTimer)
767
+ SyntaxCheckTimer->stopTimer ();
768
+ }
752
769
if ((Mode & AM_Path) && checkerMgr->hasPathSensitiveCheckers ()) {
753
770
RunPathSensitiveChecks (D, IMode, VisitedCallees);
754
771
if (IMode != ExprEngine::Inline_Minimal)
@@ -775,8 +792,12 @@ void AnalysisConsumer::RunPathSensitiveChecks(Decl *D,
775
792
ExprEngine Eng (CTU, *Mgr, VisitedCallees, &FunctionSummaries, IMode);
776
793
777
794
// Execute the worklist algorithm.
795
+ if (ExprEngineTimer)
796
+ ExprEngineTimer->startTimer ();
778
797
Eng.ExecuteWorkList (Mgr->getAnalysisDeclContextManager ().getStackFrame (D),
779
798
Mgr->options .MaxNodesPerTopLevelFunction );
799
+ if (ExprEngineTimer)
800
+ ExprEngineTimer->stopTimer ();
780
801
781
802
if (!Mgr->options .DumpExplodedGraphTo .empty ())
782
803
Eng.DumpGraph (Mgr->options .TrimGraph , Mgr->options .DumpExplodedGraphTo );
@@ -786,7 +807,11 @@ void AnalysisConsumer::RunPathSensitiveChecks(Decl *D,
786
807
Eng.ViewGraph (Mgr->options .TrimGraph );
787
808
788
809
// Display warnings.
810
+ if (BugReporterTimer)
811
+ BugReporterTimer->startTimer ();
789
812
Eng.getBugReporter ().FlushReports ();
813
+ if (BugReporterTimer)
814
+ BugReporterTimer->stopTimer ();
790
815
}
791
816
792
817
// ===----------------------------------------------------------------------===//
0 commit comments