[llvm] [llvm-reduce] Add a pass to replace unconditinal branches with returns (PR #180993)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 11 10:55:53 PST 2026
================
@@ -74,3 +74,40 @@ void llvm::reduceConditionalsFalseDeltaPass(Oracle &O,
ReducerWorkItem &WorkItem) {
reduceConditionals(O, WorkItem, false);
}
+
+void llvm::reduceUnconditionalBranchDeltaPass(Oracle &O,
+ ReducerWorkItem &WorkItem) {
+ Module &M = WorkItem.getModule();
+ LLVMContext &Ctx = M.getContext();
+
+ for (Function &F : M) {
+ if (F.isDeclaration())
+ continue;
+
+ SmallVector<BasicBlock *, 16> ToSimplify;
+
+ Type* RetTy = F.getReturnType();
+
+ for (auto &BB : F) {
+ auto *BR = dyn_cast<BranchInst>(BB.getTerminator());
+ if (!BR || !BR->isUnconditional())
+ continue;
+
+ if(O.shouldKeep())
----------------
arsenm wrote:
```suggestion
if (O.shouldKeep())
```
https://github.com/llvm/llvm-project/pull/180993
More information about the llvm-commits
mailing list