aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorUtkarsh Saxena <usx@google.com>2021-03-22 15:40:37 +0100
committerUtkarsh Saxena <usx@google.com>2021-03-25 18:54:15 +0100
commitaa979084dffba86a3e170826b4e89d90820bb78b (patch)
tree21baa5d873d17ae04e613accd2d4f19922c67602 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parent27899112c69836cb1e7bbb58df2f3471a882292c (diff)
downloadllvm-aa979084dffba86a3e170826b4e89d90820bb78b.zip
llvm-aa979084dffba86a3e170826b4e89d90820bb78b.tar.gz
llvm-aa979084dffba86a3e170826b4e89d90820bb78b.tar.bz2
[clang][Syntax] Optimize expandedTokens for token ranges.
`expandedTokens(SourceRange)` used to do a binary search to get the expanded tokens belonging to a source range. Each binary search uses `isBeforeInTranslationUnit` to order two source locations. This is inherently very slow. By profiling clangd we found out that users like clangd::SelectionTree spend 95% of time in `isBeforeInTranslationUnit`. Also it is worth noting that users of `expandedTokens(SourceRange)` majorly use ranges provided by AST to query this funciton. The ranges provided by AST are token ranges (starting at the beginning of a token and ending at the beginning of another token). Therefore we can avoid the binary search in majority of the cases by maintaining an index of ExpandedToken by their SourceLocations. We still do binary search for ranges which are not token ranges but such instances are quite low. Performance: `~/build/bin/clangd --check=clang/lib/Serialization/ASTReader.cpp` Before: Took 2:10s to complete. Now: Took 1:13s to complete. Differential Revision: https://reviews.llvm.org/D99086
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
0 files changed, 0 insertions, 0 deletions