[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

Devin Coughlin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 18:17:21 PDT 2017

dcoughlin requested changes to this revision.
dcoughlin added a comment.
This revision now requires changes to proceed.

Apologies for the delay reviewing! As I noted inline, I'm pretty worried about the performance impact of this. Is it possible to do the analysis in a single traversal of the translation unit?

Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:123
+  // Is variable changed anywhere in TU?
+  for (const Decl *D : AMgr.getASTContext().getTranslationUnitDecl()->decls()) {
+    if (isChanged(D, VD))
Since you are calling `getInitialStateForGlobalStaticVar()` in `getInitialState()` for each static variable declaration and `getInitialState()` is called for each top-level function, you are doing an n^3 operation in the size of the translation unit, which is going to be very, very expensive for large translation units.

Have you considered doing the analysis for static variables that are never changed during call-graph construction? This should be a linear operation and doing it during call-graph construction would avoid an extra walk of the entire translation unit.



More information about the cfe-commits mailing list