[PATCH] D47155: [analyzer] Reduce simplifySVal complexity threshold further.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 21 12:25:39 PDT 2018


NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, rnkovacs.
Herald added subscribers: cfe-commits, baloghadamsoftware.

Reported by Mikael Holmén on http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180416/225349.html - a combination of https://reviews.llvm.org/rC329780 and https://reviews.llvm.org/rC300178 caused a performance regression that seemed to be a hang on the attached test case.

Reducing even further from 20 to 10 gives a ~15% further speed boost on the test, but i don't think it's worth it because such code is not common and therefore accuracy is more important.


Repository:
  rC Clang

https://reviews.llvm.org/D47155

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/hangs.c


Index: test/Analysis/hangs.c
===================================================================
--- /dev/null
+++ test/Analysis/hangs.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker core -verify %s
+
+// expected-no-diagnostics
+
+// Stuff that used to hang.
+
+int g();
+
+int f(int y) {
+  return y + g();
+}
+
+int produce_a_very_large_symbol(int x) {
+  return f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
+             f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(x))))))))))))))))))))))))))))))));
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1274,7 +1274,7 @@
     SVal VisitNonLocSymbolVal(nonloc::SymbolVal V) {
       // Simplification is much more costly than computing complexity.
       // For high complexity, it may be not worth it.
-      if (V.getSymbol()->computeComplexity() > 100)
+      if (V.getSymbol()->computeComplexity() > 20)
         return V;
       return Visit(V.getSymbol());
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47155.147833.patch
Type: text/x-patch
Size: 1091 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180521/7223906d/attachment.bin>


More information about the cfe-commits mailing list