Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit d4aeb80

Browse files
committed
Bail out the LiveVariables analysis when the CFG is very large, as
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
1 parent 371b477 commit d4aeb80

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Diff for: lib/Analysis/LiveVariables.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ LiveVariables::computeLiveness(AnalysisDeclContext &AC,
486486
if (!cfg)
487487
return 0;
488488

489+
// The analysis currently has scalability issues for very large CFGs.
490+
// Bail out if it looks too large.
491+
if (cfg->getNumBlockIDs() > 300000)
492+
return 0;
493+
489494
LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign);
490495

491496
// Construct the dataflow worklist. Enqueue the exit block as the

Diff for: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "clang/Analysis/Analyses/LiveVariables.h"
1415
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
1516
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
1617
#include "clang/StaticAnalyzer/Core/PathSensitive/Calls.h"
@@ -244,6 +245,11 @@ bool ExprEngine::shouldInlineDecl(const Decl *D, ExplodedNode *Pred) {
244245
if (isa<CXXConstructorDecl>(D))
245246
return false;
246247

248+
// It is possible that the live variables analysis cannot be
249+
// run. If so, bail out.
250+
if (!CalleeADC->getAnalysis<RelaxedLiveVariables>())
251+
return false;
252+
247253
return true;
248254
}
249255

Diff for: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ void AnalysisConsumer::ActionExprEngine(Decl *D, bool ObjCGCEnabled,
523523
if (!Mgr->getCFG(D))
524524
return;
525525

526+
// See if the LiveVariables analysis scales.
527+
if (!Mgr->getAnalysisDeclContext(D)->getAnalysis<RelaxedLiveVariables>())
528+
return;
529+
526530
ExprEngine Eng(*Mgr, ObjCGCEnabled, VisitedCallees, &FunctionSummaries);
527531

528532
// Set the graph auditor.

0 commit comments

Comments
 (0)