[all-commits] [llvm/llvm-project] 6eb372: [clang-tidy] Improve performance of misc-const-cor...

Piotr Zegar via All-commits all-commits at lists.llvm.org
Tue Jan 9 09:22:16 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6eb372e4e46a6dc4511f454b6501e93eb4cad22d
      https://github.com/llvm/llvm-project/commit/6eb372e4e46a6dc4511f454b6501e93eb4cad22d
  Author: Piotr Zegar <me at piotrzegar.pl>
  Date:   2024-01-09 (Tue, 09 Jan 2024)

  Changed paths:
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang/lib/Analysis/ExprMutationAnalyzer.cpp

  Log Message:
  -----------
  [clang-tidy] Improve performance of misc-const-correctness (#72705)

Replaced certain AST matchers in ExprMutationAnalyzer with a more direct
utilization of AST classes. The primary bottleneck was identified in the
canResolveToExpr AST matcher. Since this matcher was employed multiple
times and used recursively, each invocation led to the constant creation
and destruction of other matchers within it. Additionally, the continual
comparison of DynTypedNode resulted in significant performance
degradation.

The optimization was tested on the TargetLowering.cpp file. Originally,
the check took 156 seconds on that file, but after implementing this
enhancement, it now takes approximately 40 seconds, making it nearly
four times faster.

Despite this improvement, there are still numerous issues in this file.
To further reduce the computational cost of this class, it is advisable
to consider removing the remaining matchers and exploring alternatives
such as leveraging RecursiveASTVisitor and increasing the direct use of
AST classes.

Closes #71786




More information about the All-commits mailing list