]> granicus.if.org Git - clang/commitdiff
Bail out the LiveVariables analysis when the CFG is very large, as
authorTed Kremenek <kremenek@apple.com>
Mon, 2 Jul 2012 20:21:52 +0000 (20:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 2 Jul 2012 20:21:52 +0000 (20:21 +0000)
we are encountering some scalability issues with memory usage.   The
appropriate long term fix is to make the analysis more scalable, but
this will at least prevent the analyzer swapping when
analyzing very large functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159578 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LiveVariables.cpp
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

index ff6607d51aa94469bb3f2104a869900f5cd642bf..6e10ac109278a78e402c16af76c162a416fa924e 100644 (file)
@@ -486,6 +486,11 @@ LiveVariables::computeLiveness(AnalysisDeclContext &AC,
   if (!cfg)
     return 0;
 
+  // The analysis currently has scalability issues for very large CFGs.
+  // Bail out if it looks too large.
+  if (cfg->getNumBlockIDs() > 300000)
+    return 0;
+
   LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign);
 
   // Construct the dataflow worklist.  Enqueue the exit block as the
index 3761f9c10a6f5de6d98d7962078aba9d066b3723..44b4e31f03ca96a832aa698aeee8777f009ec221 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/Analysis/Analyses/LiveVariables.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Calls.h"
@@ -244,6 +245,11 @@ bool ExprEngine::shouldInlineDecl(const Decl *D, ExplodedNode *Pred) {
   if (isa<CXXConstructorDecl>(D))
     return false;
 
+  // It is possible that the live variables analysis cannot be
+  // run.  If so, bail out.
+  if (!CalleeADC->getAnalysis<RelaxedLiveVariables>())
+    return false;
+
   return true;
 }
 
index 05fb0155f13e82914d95ad29f161e19b26d9e5c9..520a975bda5b58f8cbca851e8f2fb668aa2212cf 100644 (file)
@@ -523,6 +523,10 @@ void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled,
   if (!Mgr->getCFG(D))
     return;
 
+  // See if the LiveVariables analysis scales.
+  if (!Mgr->getAnalysisDeclContext(D)->getAnalysis<RelaxedLiveVariables>())
+    return;
+
   ExprEngine Eng(*Mgr, ObjCGCEnabled, VisitedCallees, &FunctionSummaries);
 
   // Set the graph auditor.