[llvm] 4081df4 - [llvm-reduce] Remove unnecessary loop.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 14 13:06:56 PST 2021
Author: Florian Hahn
Date: 2021-11-14T21:03:21Z
New Revision: 4081df43b6dcf712888d770e5988084b773864c6
URL: https://github.com/llvm/llvm-project/commit/4081df43b6dcf712888d770e5988084b773864c6
DIFF: https://github.com/llvm/llvm-project/commit/4081df43b6dcf712888d770e5988084b773864c6.diff
LOG: [llvm-reduce] Remove unnecessary loop.
After cd8aa234fdd2, there's no need to collect a vector of basic blocks
to keep first. Remove the first loop.
Added:
Modified:
llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
index 59d0cd910a947..c76322b255372 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
@@ -90,28 +90,21 @@ removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
/// Removes out-of-chunk arguments from functions, and modifies their calls
/// accordingly. It also removes allocations of out-of-chunk arguments.
static void extractBasicBlocksFromModule(Oracle &O, Module &Program) {
- std::vector<BasicBlock *> InitBBsToKeep;
+ DenseSet<BasicBlock *> BBsToKeep;
- for (auto &F : Program)
- for (auto &BB : F)
- if (O.shouldKeep())
- InitBBsToKeep.push_back(&BB);
-
- // We create a vector first, then convert it to a set, so that we don't have
- // to pay the cost of rebalancing the set frequently if the order we insert
- // the elements doesn't match the order they should appear inside the set.
- DenseSet<BasicBlock *> BBsToKeep(InitBBsToKeep.begin(), InitBBsToKeep.end());
-
- std::vector<BasicBlock *> BBsToDelete;
- for (auto &F : Program)
+ SmallVector<BasicBlock *> BBsToDelete;
+ for (auto &F : Program) {
for (auto &BB : F) {
- if (!BBsToKeep.count(&BB)) {
+ if (O.shouldKeep())
+ BBsToKeep.insert(&BB);
+ else {
BBsToDelete.push_back(&BB);
// Remove out-of-chunk BB from successor phi nodes
for (auto *Succ : successors(&BB))
Succ->removePredecessor(&BB);
}
}
+ }
// Replace terminators that reference out-of-chunk BBs
for (auto &F : Program)
More information about the llvm-commits
mailing list