aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorDwight Guth <dwight.guth@runtimeverification.com>2021-10-29 10:06:04 -0700
committerArthur Eubanks <aeubanks@google.com>2021-10-29 10:06:26 -0700
commit2f1617362751f2bff41014bc7364b24ec0ff3f47 (patch)
tree77868cd562331e7fedf4b2e090b632f28a2620af /clang/lib/Basic/FileManager.cpp
parent4dd540d9c89810b5b41d633e136bf02f890113f0 (diff)
downloadllvm-2f1617362751f2bff41014bc7364b24ec0ff3f47.zip
llvm-2f1617362751f2bff41014bc7364b24ec0ff3f47.tar.gz
llvm-2f1617362751f2bff41014bc7364b24ec0ff3f47.tar.bz2
[llvm-reduce] optimize extractFromModule functions
The extractBasicBlocksFromModule, extractInstrFromModule, and other similar functions previously performed very poorly when the number of such elements in the program to reduce was very high. Previously, we were creating the set which caches elements to keep by looping through all elements in the module and adding them to the set. However, since std::set is an ordered set, this introduces a massive amount of rebalancing if the order of elements in the program and the order of their pointers in memory are not the same. The solution is straightforward: first put all the elements to be kept in a vector, then use the constructor for std::set which takes a pair of iterators over a collection. This constructor is optimized to avoid doing unnecessary work when initializing large sets. Also in this change, we pass BBsToKeep set to functions replaceBranchTerminator and removeUninterestingBBsFromSwitch as a const reference rather than passing it by value. This ought to prevent the need to copy the collection each time these functions are called, which is expensive if the collection is large. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D112757
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
0 files changed, 0 insertions, 0 deletions