Skip to content

llvm-reduce: Use simpleSimplifyCFG in block reduction #135028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/test/tools/llvm-reduce/remove-bb-switch-default.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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();
}
}
Expand Down