[all-commits] [llvm/llvm-project] 2f1617: [llvm-reduce] optimize extractFromModule functions
Dwight Guth via All-commits
all-commits at lists.llvm.org
Fri Oct 29 10:08:12 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2f1617362751f2bff41014bc7364b24ec0ff3f47
https://github.com/llvm/llvm-project/commit/2f1617362751f2bff41014bc7364b24ec0ff3f47
Author: Dwight Guth <dwight.guth at runtimeverification.com>
Date: 2021-10-29 (Fri, 29 Oct 2021)
Changed paths:
M llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
M llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
M llvm/tools/llvm-reduce/deltas/ReduceGlobalVars.cpp
M llvm/tools/llvm-reduce/deltas/ReduceInstructions.cpp
Log Message:
-----------
[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
More information about the All-commits
mailing list