[analyzer] Implement "do not inline large functions many times"
authorAnna Zaks <ganna@apple.com>
Mon, 17 Dec 2012 20:08:51 +0000 (20:08 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 17 Dec 2012 20:08:51 +0000 (20:08 +0000)
commitd53182b0dfcc7402bda7ef1589dc933c2b84f4df
treeb2ed538a9ed3d3f1bf24ec343b3148b8f6c41c80
parent62a144f099ae2ce7e225a129fed5e1065f1cf454
[analyzer] Implement "do not inline large functions many times"
performance heuristic

After inlining a function with more than 13 basic blocks 32 times, we
are not going to inline it anymore. The idea is that inlining large
functions leads to drastic performance implications. Since the function
has already been inlined, we know that we've analyzed it in many
contexts.

The following metrics are used:
 - Large function is a function with more than 13 basic blocks (we
should switch to another metric, like cyclomatic complexity)
 - We consider that we've inlined a function many times if it's been
inlined 32 times. This number is configurable with -analyzer-config
max-times-inline-large=xx

This heuristic addresses a performance regression introduced with
inlining on one benchmark. The analyzer on this benchmark became 60
times slower with inlining turned on. The heuristic allows us to analyze
it in 24% of the time. The performance improvements on the other
benchmarks I've tested with are much lower - under 10%, which is
expected.

llvm-svn: 170361
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/analyzer-config.cpp