[PATCH] D80202: [ASTMatchers] Performance optimization for memoization

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 7 02:30:45 PDT 2020


sammccall added inline comments.


================
Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:902
   // Maps (matcher, node) -> the match result for memoization.
-  typedef std::map<MatchKey, MemoizedMatchResult> MemoizationMap;
+  typedef std::map<MatchKey, MemoizedMatchResult, std::less<>> MemoizationMap;
   MemoizationMap ResultCache;
----------------
klimek wrote:
> Ok, if this actually matters, we should also not use a std::map here, but a llvm::DenseMap (or do we rely on iteration invalidation semantics here?).
Belated +1. 5% seems like this performance *does* matter, so DenseMap::find_as should be yet faster.
It looks like BoundNodesTreeBuilder would need a DenseMapInfo, but all the other members are hashable already.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80202/new/

https://reviews.llvm.org/D80202





More information about the cfe-commits mailing list