This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] MinComplexityConstraint now early exits and only does one macro stack lookup
ClosedPublic

Authored by teemperor on Jun 19 2017, 12:48 PM.

Details

Summary

This patch contains performance improvements for the MinComplexityConstraint. It reduces the constraint time when running on the SQLite codebase by around 43% (from 0.085s down to 0.049s).

The patch is essentially doing two things:

  • It introduces a possibility for the complexity value to early exit when reaching the limit we were checking for. This means that once we noticed that the current clone is larger than the limit the user has set, we instantly exit and no longer traverse the tree or do further expensive lookups in the macro stack.
  • It also removes half of the macro stack lookups we do so far. Previously we always checked the start and the end location of a Stmt for macros, which was only a middle way between checking all locations of the Stmt and just checking one location. In practice I rarely found cases where it really matters if we check start/end or just the start of a statement as code with lots of macros that somehow just produce half a statement are very rare.

Diff Detail

Repository
rL LLVM

Event Timeline

teemperor created this revision.Jun 19 2017, 12:48 PM
teemperor updated this revision to Diff 113692.Sep 3 2017, 6:44 AM
  • Rebased and fixed merge conflicts before merging.
This revision was automatically updated to reflect the committed changes.