diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-11-10 23:26:10 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-11-10 23:26:10 +0000 |
commit | 20be0b4397a03bfd30364d5083b4207aded5b28f (patch) | |
tree | 0b4eb30cb2622f1a32ff7d0ba918e2913d75d796 | |
parent | 9bded9dc24fbc259dcaee875879194631477246a (diff) | |
download | bcm5719-llvm-20be0b4397a03bfd30364d5083b4207aded5b28f.tar.gz bcm5719-llvm-20be0b4397a03bfd30364d5083b4207aded5b28f.zip |
[static analyzer]: only call RemoveDeadBindings() when analyzing non-Expr stmts, entering a basic block, or analyzing non-consumed expressions. This sigificantly speeds up analysis time, and reduces analysis time down to 27% less than before we linearized the CFG.
llvm-svn: 144332
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 32cfa847e9e..eeb3451384f 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -220,6 +220,29 @@ void ExprEngine::processCFGElement(const CFGElement E, ExplodedNode *Pred, currentBuilderContext = 0; } +static bool shouldRemoveDeadBindings(AnalysisManager &AMgr, + const CFGStmt S, + const ExplodedNode *Pred, + const LocationContext *LC) { + + // Are we never purging state values? + if (AMgr.getPurgeMode() == PurgeNone) + return false; + + // Is this the beginning of a basic block? + if (!isa<StmtPoint>(Pred->getLocation())) + return true; + + // Is this on a non-expression? + if (!isa<Expr>(S.getStmt())) + return true; + + // Is this an expression that is consumed by another expression? If so, + // postpone cleaning out the state. + ParentMap &PM = LC->getAnalysisDeclContext()->getParentMap(); + return !PM.isConsumedExpr(cast<Expr>(S.getStmt())); +} + void ExprEngine::ProcessStmt(const CFGStmt S, ExplodedNode *Pred) { // TODO: Use RAII to remove the unnecessary, tagged nodes. @@ -244,7 +267,7 @@ void ExprEngine::ProcessStmt(const CFGStmt S, const LocationContext *LC = EntryNode->getLocationContext(); SymbolReaper SymReaper(LC, currentStmt, SymMgr, getStoreManager()); - if (AMgr.getPurgeMode() != PurgeNone) { + if (shouldRemoveDeadBindings(AMgr, S, Pred, LC)) { getCheckerManager().runCheckersForLiveSymbols(CleanedState, SymReaper); const StackFrameContext *SFC = LC->getCurrentStackFrame(); |