@@ -196,7 +196,9 @@ class AnalysisConsumer : public AnalysisASTConsumer,
196196
197197  // / Time the analyzes time of each translation unit.
198198  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;
200202
201203  // / The information about analyzed functions shared throughout the
202204  // / translation unit.
@@ -212,8 +214,13 @@ class AnalysisConsumer : public AnalysisASTConsumer,
212214    if  (Opts->PrintStats  || Opts->ShouldSerializeStats ) {
213215      AnalyzerTimers = llvm::make_unique<llvm::TimerGroup>(
214216          " 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);
217224      llvm::EnableStatistics (/*  PrintOnExit= */   false );
218225    }
219226  }
@@ -346,8 +353,13 @@ class AnalysisConsumer : public AnalysisASTConsumer,
346353  // / Handle callbacks for arbitrary Decls.
347354  bool  VisitDecl (Decl *D) {
348355    AnalysisMode Mode = getModeForDecl (D, RecVisitorMode);
349-     if  (Mode & AM_Syntax)
356+     if  (Mode & AM_Syntax) {
357+       if  (SyntaxCheckTimer)
358+         SyntaxCheckTimer->startTimer ();
350359      checkerMgr->runCheckersOnASTDecl (D, *Mgr, *RecVisitorBR);
360+       if  (SyntaxCheckTimer)
361+         SyntaxCheckTimer->stopTimer ();
362+     }
351363    return  true ;
352364  }
353365
@@ -566,7 +578,11 @@ static bool isBisonFile(ASTContext &C) {
566578void  AnalysisConsumer::runAnalysisOnTranslationUnit (ASTContext &C) {
567579  BugReporter BR (*Mgr);
568580  TranslationUnitDecl *TU = C.getTranslationUnitDecl ();
581+   if  (SyntaxCheckTimer)
582+     SyntaxCheckTimer->startTimer ();
569583  checkerMgr->runCheckersOnASTDecl (TU, *Mgr, BR);
584+   if  (SyntaxCheckTimer)
585+     SyntaxCheckTimer->stopTimer ();
570586
571587  //  Run the AST-only checks using the order in which functions are defined.
572588  //  If inlining is not turned on, use the simplest function order for path
@@ -608,8 +624,6 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
608624  if  (Diags.hasErrorOccurred () || Diags.hasFatalErrorOccurred ())
609625    return ;
610626
611-   if  (TUTotalTimer) TUTotalTimer->startTimer ();
612- 
613627  if  (isBisonFile (C)) {
614628    reportAnalyzerProgress (" Skipping bison-generated file\n "  );
615629  } else  if  (Opts->DisableAllChecks ) {
@@ -622,8 +636,6 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
622636    runAnalysisOnTranslationUnit (C);
623637  }
624638
625-   if  (TUTotalTimer) TUTotalTimer->stopTimer ();
626- 
627639  //  Count how many basic blocks we have not covered.
628640  NumBlocksInAnalyzedFunctions = FunctionSummaries.getTotalNumBasicBlocks ();
629641  NumVisitedBlocksInAnalyzedFunctions =
@@ -747,8 +759,13 @@ void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
747759
748760  BugReporter BR (*Mgr);
749761
750-   if  (Mode & AM_Syntax)
762+   if  (Mode & AM_Syntax) {
763+     if  (SyntaxCheckTimer)
764+       SyntaxCheckTimer->startTimer ();
751765    checkerMgr->runCheckersOnASTBody (D, *Mgr, BR);
766+     if  (SyntaxCheckTimer)
767+       SyntaxCheckTimer->stopTimer ();
768+   }
752769  if  ((Mode & AM_Path) && checkerMgr->hasPathSensitiveCheckers ()) {
753770    RunPathSensitiveChecks (D, IMode, VisitedCallees);
754771    if  (IMode != ExprEngine::Inline_Minimal)
@@ -775,8 +792,12 @@ void AnalysisConsumer::RunPathSensitiveChecks(Decl *D,
775792  ExprEngine Eng (CTU, *Mgr, VisitedCallees, &FunctionSummaries, IMode);
776793
777794  //  Execute the worklist algorithm.
795+   if  (ExprEngineTimer)
796+     ExprEngineTimer->startTimer ();
778797  Eng.ExecuteWorkList (Mgr->getAnalysisDeclContextManager ().getStackFrame (D),
779798                      Mgr->options .MaxNodesPerTopLevelFunction );
799+   if  (ExprEngineTimer)
800+     ExprEngineTimer->stopTimer ();
780801
781802  if  (!Mgr->options .DumpExplodedGraphTo .empty ())
782803    Eng.DumpGraph (Mgr->options .TrimGraph , Mgr->options .DumpExplodedGraphTo );
@@ -786,7 +807,11 @@ void AnalysisConsumer::RunPathSensitiveChecks(Decl *D,
786807    Eng.ViewGraph (Mgr->options .TrimGraph );
787808
788809  //  Display warnings.
810+   if  (BugReporterTimer)
811+     BugReporterTimer->startTimer ();
789812  Eng.getBugReporter ().FlushReports ();
813+   if  (BugReporterTimer)
814+     BugReporterTimer->stopTimer ();
790815}
791816
792817// ===----------------------------------------------------------------------===//
0 commit comments