From 4081df43b6dcf712888d770e5988084b773864c6 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 13 Nov 2021 20:05:58 +0000 Subject: [PATCH] [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. --- llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp index 59d0cd9..c76322b 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 InitBBsToKeep; + DenseSet 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 BBsToKeep(InitBBsToKeep.begin(), InitBBsToKeep.end()); - - std::vector BBsToDelete; - for (auto &F : Program) + SmallVector 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) -- 2.7.4