[llvm-branch-commits] [llvm] llvm-reduce: Support exotic terminators in instructions-to-return (PR #134794)
Nikita Popov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 2 05:28:35 PDT 2025
================
@@ -73,28 +73,16 @@ static void rewriteFuncWithReturnType(Function &OldF, Value *NewRetValue) {
}
}
- // Now prune any CFG edges we have to deal with.
- //
- // Use KeepOneInputPHIs in case the instruction we are using for the return is
- // that phi.
- // TODO: Could avoid this with fancier iterator management.
- for (BasicBlock *Succ : successors(NewRetBlock))
- Succ->removePredecessor(NewRetBlock, /*KeepOneInputPHIs=*/true);
-
- // Now delete the tail of this block, in reverse to delete uses before defs.
- for (Instruction &I : make_early_inc_range(
- make_range(NewRetBlock->rbegin(), NewValIt.getReverse()))) {
- Value *Replacement = getDefaultValue(I.getType());
- I.replaceAllUsesWith(Replacement);
- I.eraseFromParent();
- }
+ // If we're returning an instruction, split the basic block so we can let
+ // EliminateUnreachableBlocks cleanup the successors.
----------------
nikic wrote:
```suggestion
// simpleSimplifyCFG cleanup the successors.
```
https://github.com/llvm/llvm-project/pull/134794
More information about the llvm-branch-commits
mailing list