[PATCH] D129205: [BasicBlockUtils] Allow splitting predecessors with callbr terminators

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 07:41:51 PDT 2022


nikic created this revision.
nikic added reviewers: nickdesaulniers, nathanchance, craig.topper.
Herald added subscribers: StephenFan, asbirlea, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

SplitBlockPredecessors currently asserts if one of the predecessor terminators is a callbr. This limitation was originally necessary, because just like with indirectbr, it was not possible to replace successors of a callbr. However, this is no longer the case since D67252 <https://reviews.llvm.org/D67252>. As the requirement nowadays is that callbr must reference all blockaddrs directly in the call arguments, and these get automatically updated when setSuccessor() is called, we no longer need this limitation.

The only thing we need to do here is use replaceSuccessorWith() instead of replaceUsesOfWith(), because only the former does the necessary blockaddr updating magic.

I believe there's other similar limitations that can be removed, e.g. related to critical edge splitting.


https://reviews.llvm.org/D129205

Files:
  llvm/lib/Transforms/Scalar/JumpThreading.cpp
  llvm/lib/Transforms/Scalar/LICM.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/lib/Transforms/Utils/LoopUtils.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/JumpThreading/callbr-edge-split.ll
  llvm/test/Transforms/LICM/callbr-crash.ll
  llvm/test/Transforms/SimplifyCFG/jump-threading.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129205.442565.patch
Type: text/x-patch
Size: 7631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220706/62925ea5/attachment.bin>


More information about the llvm-commits mailing list