Skip to content

Commit 5587932

Browse files
authored
llvm-reduce: Use simpleSimplifyCFG in block reduction (#135028)
1 parent 98ea512 commit 5587932

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
; RESULT0-NEXT: br i1 %arg0, label %bb1, label %bb2
1717

1818
; RESULT0: bb1:
19+
; RESULT0: %bb1.phi = phi i32 [ %bb.load, %bb ], [ %bb.load, %bb2 ], [ %bb.load, %bb2 ]
1920
; RESULT0-NEXT: store i32 1, ptr null, align 4
2021
; RESULT0-NEXT: ret void
2122

llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131

3232
using namespace llvm;
3333

34+
using BlockSet = SetVector<BasicBlock *>;
35+
3436
/// Replaces BB Terminator with one that only contains Chunk BBs
3537
static void replaceBranchTerminator(BasicBlock &BB,
36-
const DenseSet<BasicBlock *> &BBsToDelete) {
38+
const BlockSet &BBsToDelete) {
3739
auto *Term = BB.getTerminator();
3840
std::vector<BasicBlock *> ChunkSuccessors;
3941
for (auto *Succ : successors(&BB)) {
@@ -104,9 +106,8 @@ static void replaceBranchTerminator(BasicBlock &BB,
104106
/// Removes uninteresting BBs from switch, if the default case ends up being
105107
/// uninteresting, the switch is replaced with a void return (since it has to be
106108
/// replace with something)
107-
static void
108-
removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
109-
const DenseSet<BasicBlock *> &BBsToDelete) {
109+
static void removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
110+
const BlockSet &BBsToDelete) {
110111
for (int I = 0, E = SwInst.getNumCases(); I != E; ++I) {
111112
auto Case = SwInst.case_begin() + I;
112113
if (BBsToDelete.count(Case->getCaseSuccessor())) {
@@ -142,7 +143,8 @@ removeUninterestingBBsFromSwitch(SwitchInst &SwInst,
142143
/// Removes out-of-chunk arguments from functions, and modifies their calls
143144
/// accordingly. It also removes allocations of out-of-chunk arguments.
144145
void llvm::reduceBasicBlocksDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
145-
DenseSet<BasicBlock *> BBsToDelete;
146+
BlockSet BBsToDelete;
147+
146148
df_iterator_default_set<BasicBlock *> Reachable;
147149

148150
for (auto &F : WorkItem.getModule()) {
@@ -183,7 +185,8 @@ void llvm::reduceBasicBlocksDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {
183185
// Cleanup any blocks that are now dead after eliminating this set. This
184186
// will likely be larger than the number of blocks the oracle told us to
185187
// delete.
186-
EliminateUnreachableBlocks(F);
188+
simpleSimplifyCFG(F, BBsToDelete.getArrayRef());
189+
187190
BBsToDelete.clear();
188191
}
189192
}

0 commit comments

Comments
 (0)