hanchenye-llvm-project/clang
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
..
INPUTS
bindings [libclang] Support for querying whether an enum is scoped 2017-07-12 11:35:11 +00:00
cmake Remove LLVMFuzzer from list of bundled libraries for Fuchsia 2017-08-23 00:09:33 +00:00
docs [modules] Add ability to specify module name to module file mapping (reapply) 2017-08-31 06:26:43 +00:00
examples
include [analyzer] Performance optimizations for the CloneChecker 2017-08-31 07:10:46 +00:00
lib [analyzer] Performance optimizations for the CloneChecker 2017-08-31 07:10:46 +00:00
runtime
test [modules] Add ability to specify module name to module file mapping (reapply) 2017-08-31 06:26:43 +00:00
tools [libclang]: Honor LIBCLANG_NOTHREADS for clang_parseTranslationUnit* 2017-08-29 09:08:02 +00:00
unittests [analyzer] Performance optimizations for the CloneChecker 2017-08-31 07:10:46 +00:00
utils Do not look through pack expansions when looking for unexpanded parameter packs. 2017-08-15 22:58:45 +00:00
www [cxx_status] Update to describe current status a bit better. 2017-08-30 23:10:31 +00:00
.arcconfig
.clang-format
.clang-tidy
.gitignore
CMakeLists.txt CMake: only try to find the Z3 package when `CLANG_ANALYZER_BUILD_Z3` is ON 2017-08-27 20:24:23 +00:00
CODE_OWNERS.TXT
INSTALL.txt
LICENSE.TXT
ModuleInfo.txt
NOTES.txt
README.txt Remove test commit. 2017-06-30 03:03:28 +00:00

README.txt

//===----------------------------------------------------------------------===//
// C Language Family Front-end
//===----------------------------------------------------------------------===//

Welcome to Clang.  This is a compiler front-end for the C family of languages
(C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM
compiler infrastructure project.

Unlike many other compiler frontends, Clang is useful for a number of things
beyond just compiling code: we intend for Clang to be host to a number of
different source-level tools.  One example of this is the Clang Static Analyzer.

If you're interested in more (including how to build Clang) it is best to read
the relevant web sites.  Here are some pointers:

Information on Clang:              http://clang.llvm.org/
Building and using Clang:          http://clang.llvm.org/get_started.html
Clang Static Analyzer:             http://clang-analyzer.llvm.org/
Information on the LLVM project:   http://llvm.org/

If you have questions or comments about Clang, a great place to discuss them is
on the Clang development mailing list:
  http://lists.llvm.org/mailman/listinfo/cfe-dev

If you find a bug in Clang, please file it in the LLVM bug tracker:
  http://llvm.org/bugs/