[cfe-commits] r159776 - in /cfe/trunk: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp utils/analyzer/SumTimerInfo.py

Anna Zaks ganna at apple.com
Thu Jul 5 13:44:03 PDT 2012


Author: zaks
Date: Thu Jul  5 15:44:02 2012
New Revision: 159776

URL: http://llvm.org/viewvc/llvm-project?rev=159776&view=rev
Log:
[analyzer] Add a statistic for maximum CFG size and a script to summarize analyzer stats from scan-build output.

Added:
    cfe/trunk/utils/analyzer/SumTimerInfo.py
Modified:
    cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=159776&r1=159775&r2=159776&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Thu Jul  5 15:44:02 2012
@@ -58,6 +58,7 @@
 STATISTIC(NumBlocksInAnalyzedFunctions,
                      "The # of basic blocks in the analyzed functions.");
 STATISTIC(PercentReachableBlocks, "The % of reachable basic blocks.");
+STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
 
 //===----------------------------------------------------------------------===//
 // Special PathDiagnosticConsumers.
@@ -488,6 +489,12 @@
     return;
 
   DisplayFunction(D, Mode);
+  CFG *DeclCFG = Mgr->getCFG(D);
+  if (DeclCFG) {
+    unsigned CFGSize = DeclCFG->size();
+    MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
+  }
+
 
   // Clear the AnalysisManager of old AnalysisDeclContexts.
   Mgr->ClearContexts();

Added: cfe/trunk/utils/analyzer/SumTimerInfo.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SumTimerInfo.py?rev=159776&view=auto
==============================================================================
--- cfe/trunk/utils/analyzer/SumTimerInfo.py (added)
+++ cfe/trunk/utils/analyzer/SumTimerInfo.py Thu Jul  5 15:44:02 2012
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+"""
+Script to Summarize statistics in the scan-build output.
+
+Statistics are enabled by passing '-internal-stats' option to scan-build 
+(or '-analyzer-stats' to the analyzer).
+
+"""
+
+import string
+from operator import itemgetter
+import sys
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        print >> sys.stderr, 'Usage: ', sys.argv[0],\
+                             'scan_build_output_file'
+        sys.exit(-1)
+
+    f = open(sys.argv[1], 'r')
+    Time = 0.0
+    TotalTime = 0.0
+    MaxTime = 0.0
+    Warnings = 0
+    Count = 0
+    FunctionsAnalyzed = 0
+    ReachableBlocks = 0
+    ReachedMaxSteps = 0
+    NumSteps = 0
+    MaxCFGSize = 0
+    Mode = 1
+    for line in f:
+        if ("Miscellaneous Ungrouped Timers" in line) :
+          Mode = 1
+        if (("Analyzer Total Time" in line) and (Mode == 1)) :
+          s = line.split()
+          Time = Time + float(s[6])
+          Count = Count + 1
+          if (float(s[6]) > MaxTime) :
+            MaxTime = float(s[6])
+        if ((("warning generated." in line) or ("warnings generated." in line)) and Mode == 1) :
+          s = line.split()
+          Warnings = Warnings + int(s[0])
+        if (("The # of functions analysed (as top level)." in line) and (Mode == 1)) :
+          s = line.split()
+          FunctionsAnalyzed = FunctionsAnalyzed + int(s[0])
+        if (("The % of reachable basic blocks" in line) and (Mode == 1)) :
+          s = line.split()
+          ReachableBlocks = ReachableBlocks + int(s[0])
+        if (("The # of times we reached the max number of steps." in line) and (Mode == 1)) :
+          s = line.split()
+          ReachedMaxSteps = ReachedMaxSteps + int(s[0])
+        if (("The maximum number of basic blocks in a function" in line) and (Mode == 1)) :
+          s = line.split()
+          if (MaxCFGSize < int(s[0])) :
+            MaxCFGSize = int(s[0])
+        if (("The # of steps executed." in line) and (Mode == 1)) :
+          s = line.split()
+          NumSteps = NumSteps + int(s[0])
+        if ((")  Total" in line) and (Mode == 1)) :
+          s = line.split()
+          TotalTime = TotalTime + float(s[6])
+          
+    print "TU Count %d" % (Count)
+    print "Time %f" % (Time)
+    print "Warnings %d" % (Warnings)
+    print "Functions Analyzed %d" % (FunctionsAnalyzed)
+    print "Reachable Blocks %d" % (ReachableBlocks)
+    print "Reached Max Steps %d" % (ReachedMaxSteps)
+    print "Number of Steps %d" % (NumSteps)
+    print "MaxTime %f" % (MaxTime)
+    print "TotalTime %f" % (TotalTime)
+    print "Max CFG Size %d" % (MaxCFGSize)
+    
\ No newline at end of file





More information about the cfe-commits mailing list