aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-08-31 13:08:20 -0700
committerNick Desaulniers <ndesaulniers@google.com>2022-08-31 13:23:00 -0700
commitab6876a40d06e7a30a2ab7c7dcb3440672e201ea (patch)
treeef8ca9e4a78802211fd9efdd947c377211185830 /llvm/lib/Transforms/Utils/Local.cpp
parent2928b230ce0e23b07c57470af5b830019b314951 (diff)
downloadllvm-ab6876a40d06e7a30a2ab7c7dcb3440672e201ea.zip
llvm-ab6876a40d06e7a30a2ab7c7dcb3440672e201ea.tar.gz
llvm-ab6876a40d06e7a30a2ab7c7dcb3440672e201ea.tar.bz2
reland: [Local] Allow creating callbr with duplicate successors
Since D129288, callbr is allowed to have duplicate successors. This patch removes a limitation which prevents optimizations from actually producing such callbrs. This is probably the riskiest of all the recent callbr changes, because code with incorrect assumptions might be lurking somewhere. I fixed the one case I encountered ahead of time in https://github.com/llvm/llvm-project/commit/8201e3ef5c84561260218bc041209611aac690e3. Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D129997 Originally landed as commit 08860f525a23 ("[Local] Allow creating callbr with duplicate successors") Reverted in commit 1cf6b93df168 ("Revert "[Local] Allow creating callbr with duplicate successors"")
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp12
1 files changed, 0 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index c1735f7..1115b0b 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1090,18 +1090,6 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
}
}
- // We cannot fold the block if it's a branch to an already present callbr
- // successor because that creates duplicate successors.
- for (BasicBlock *PredBB : predecessors(BB)) {
- if (auto *CBI = dyn_cast<CallBrInst>(PredBB->getTerminator())) {
- if (Succ == CBI->getDefaultDest())
- return false;
- for (unsigned i = 0, e = CBI->getNumIndirectDests(); i != e; ++i)
- if (Succ == CBI->getIndirectDest(i))
- return false;
- }
- }
-
LLVM_DEBUG(dbgs() << "Killing Trivial BB: \n" << *BB);
SmallVector<DominatorTree::UpdateType, 32> Updates;