[llvm] 5587932 - llvm-reduce: Use simpleSimplifyCFG in block reduction (#135028)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 21:12:28 PDT 2025
Author: Matt Arsenault
Date: 2025-04-10T06:12:24+02:00
New Revision: 5587932e20ff90ba8a28f3c9089e8b12e42b09b5
URL: https://github.com/llvm/llvm-project/commit/5587932e20ff90ba8a28f3c9089e8b12e42b09b5
DIFF: https://github.com/llvm/llvm-project/commit/5587932e20ff90ba8a28f3c9089e8b12e42b09b5.diff
LOG: llvm-reduce: Use simpleSimplifyCFG in block reduction (#135028)
Added:
Modified:
llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll
llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll b/llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll
index 34a2286afad4e..b509d1181f74d 100644
--- a/llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll
+++ b/llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll
@@ -16,6 +16,7 @@
; RESULT0-NEXT: br i1 %arg0, label %bb1, label %bb2
; RESULT0: bb1:
+; RESULT0: %bb1.phi = phi i32 [ %bb.load, %bb ], [ %bb.load, %bb2 ], [ %bb.load, %bb2 ]
; RESULT0-NEXT: store i32 1, ptr null, align 4
; RESULT0-NEXT: ret void
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
index 5656fdda764a4..a7767b5e4233d 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
@@ -31,9 +31,11 @@
using namespace llvm;
+using BlockSet = SetVector<BasicBlock *>;
+
/// Replaces BB Terminator with one that only contains Chunk BBs
static void replaceBranchTerminator(BasicBlock &BB,
- const DenseSet<BasicBlock *> &BBsToDelete) {
+ const BlockSet &BBsToDelete) {
auto *Term = BB.getTerminator();
std::vector<BasicBlock *> ChunkSuccessors;
for (auto *Succ : successors(&BB)) {
@@ -104,9 +106,8 @@ static void replaceBranchTerminator(BasicBlock &BB,
/// Removes uninteresting BBs from switch, if the default case ends up being
/// uninteresting, the switch is replaced with a void return (since it has to be
/// replace with something)
-static void
-removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
- const DenseSet<BasicBlock *> &BBsToDelete) {
+static void removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
+ const BlockSet &BBsToDelete) {
for (int I = 0, E = SwInst.getNumCases(); I != E; ++I) {
auto Case = SwInst.case_begin() + I;
if (BBsToDelete.count(Case->getCaseSuccessor())) {
@@ -142,7 +143,8 @@ removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
/// Removes out-of-chunk arguments from functions, and modifies their calls
/// accordingly. It also removes allocations of out-of-chunk arguments.
void llvm::reduceBasicBlocksDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
- DenseSet<BasicBlock *> BBsToDelete;
+ BlockSet BBsToDelete;
+
df_iterator_default_set<BasicBlock *> Reachable;
for (auto &F : WorkItem.getModule()) {
@@ -183,7 +185,8 @@ void llvm::reduceBasicBlocksDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
// Cleanup any blocks that are now dead after eliminating this set. This
// will likely be larger than the number of blocks the oracle told us to
// delete.
- EliminateUnreachableBlocks(F);
+ simpleSimplifyCFG(F, BBsToDelete.getArrayRef());
+
BBsToDelete.clear();
}
}
More information about the llvm-commits
mailing list