llvm-project/clang/lib/Analysis
Raphael Isemann 70686a1590 [analyzer] Performance optimizations for the CloneChecker
Summary:
This patch  aims at optimizing the CloneChecker for larger programs. Before this
patch we took around 102 seconds to analyze sqlite3 with a complexity value of
50. After this patch we now take 2.1 seconds to analyze sqlite3.

The biggest performance optimization is that we now put the constraint for group
size before the constraint for the complexity. The group size constraint is much
faster in comparison to the complexity constraint as it only does a simple
integer comparison. The complexity constraint on the other hand actually
traverses each Stmt and even checks the macro stack, so it is obviously not able
to handle larger amounts of incoming clones. The new order filters out all the
single-clone groups that the type II constraint generates in a faster way before
passing the fewer remaining clones to the complexity constraint. This reduced
runtime by around 95%.

The other change is that we also delay the verification part of the type II
clones back in the chain of constraints. This required to split up the
constraint into two parts - a verification and a hash constraint (which is also
making it more similar to the original design of the clone detection algorithm).
The reasoning for this is the same as before: The verification constraint has to
traverse many statements and shouldn't be at the start of the constraint chain.
However, as the type II hashing has to be the first step in our algorithm, we
have no other choice but split this constrain into two different ones. Now our
group size and complexity constrains filter out a chunk of the clones before
they reach the slow verification step, which reduces the runtime by around 8%.

I also kept the full type II constraint around - that now just calls it's two
sub-constraints - in case someone doesn't care about the performance benefits
of doing this.

Reviewers: NoQ

Reviewed By: NoQ

Subscribers: klimek, v.g.vassilev, xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D34182

llvm-svn: 312222
2017-08-31 07:10:46 +00:00
..
AnalysisDeclContext.cpp [CFG] Add LoopExit information to CFG 2017-08-19 11:19:16 +00:00
BodyFarm.cpp Encapsulate FPOptions and use it consistently 2017-03-27 19:17:25 +00:00
BodyFarm.h Make headers self-contained. 2016-02-02 11:06:57 +00:00
CFG.cpp Implement CFG construction for __try / __except / __leave. 2017-08-23 15:33:16 +00:00
CFGReachabilityAnalysis.cpp
CFGStmtMap.cpp
CMakeLists.txt Add support for __builtin_os_log_format[_buffer_size] 2016-10-24 20:39:34 +00:00
CallGraph.cpp [analyzer] Consider function call arguments while building CallGraph. 2017-01-27 12:14:56 +00:00
CloneDetection.cpp [analyzer] Performance optimizations for the CloneChecker 2017-08-31 07:10:46 +00:00
CocoaConventions.cpp Allow the cf_returns_[not_]retained attributes to appear on out-parameters. 2015-06-19 23:17:46 +00:00
CodeInjector.cpp Roll-back r250822. 2015-10-20 13:23:58 +00:00
Consumed.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
Dominators.cpp
FormatString.cpp Add support for __builtin_os_log_format[_buffer_size] 2016-10-24 20:39:34 +00:00
FormatStringParsing.h [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
LiveVariables.cpp [analyzer] Remove superquadratic behaviour from DataflowWorklist 2016-10-13 21:31:46 +00:00
OSLog.cpp Make helpers static. NFC. 2017-02-11 12:21:17 +00:00
ObjCNoReturn.cpp
PostOrderCFGView.cpp
PrintfFormatString.cpp [clang] Fix handling of "%zd" format specifier 2017-07-14 22:57:00 +00:00
ProgramPoint.cpp Roll-back r250822. 2015-10-20 13:23:58 +00:00
PseudoConstantAnalysis.cpp Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:51 +00:00
ReachableCode.cpp Fix PR13910: Don't warn that __builtin_unreachable() is unreachable 2017-04-11 15:36:06 +00:00
ScanfFormatString.cpp [clang] Fix handling of "%zd" in scanf 2017-07-20 20:11:47 +00:00
ThreadSafety.cpp Reland "Thread Safety Analysis: fix assert_capability." 2017-08-08 19:44:34 +00:00
ThreadSafetyCommon.cpp DR616, and part of P0135R1: member access (or pointer-to-member access) on a 2016-12-03 01:14:32 +00:00
ThreadSafetyLogical.cpp Revert r240270 ("Fixed/added namespace ending comments using clang-tidy"). 2015-06-22 23:07:51 +00:00
ThreadSafetyTIL.cpp Spelling mistakes in comments. NFCI. (PR27635) 2017-03-30 14:13:19 +00:00
UninitializedValues.cpp NFC small format 2016-10-29 15:28:25 +00:00