[llvm] [AMDGPU][FixIrreducible][UnifyLoopExits] Support callbr with inline-asm (PR #149308)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 28 09:04:56 PDT 2025
================
@@ -118,6 +122,34 @@ struct ControlFlowHub {
std::optional<unsigned> MaxControlFlowBooleans = std::nullopt);
SmallVector<BranchDescriptor> Branches;
+
+ /// \brief Create a new intermediate target block for a callbr edge.
+ ///
+ /// This function creates a new basic block (the "target block") that sits
+ /// between a callbr instruction and one of its successors. The callbr's
+ /// successor is rewired to this new block, and the new block unconditionally
+ /// branches to the original successor. This is useful for normalizing control
+ /// flow, e.g., when transforming irreducible loops.
+ ///
+ /// \param CallBr The callbr instruction whose edge is to be split.
+ /// \param Succ The original successor basic block to be reached.
+ /// \param SuccIdx The index of the successor in the callbr
+ /// instruction.
+ /// \param CI Optional CycleInfo for updating cycle membership.
+ /// \param DTU Optional DomTreeUpdater for updating the dominator
+ /// tree.
+ /// \param LI Optional LoopInfo for updating loop membership.
+ /// \param UpdatedLI Optional output flag indicating if LoopInfo has been
+ /// updated.
+ ///
+ /// \returns The newly created intermediate target block.
+ ///
+ /// \note This function updates PHI nodes, dominator tree, loop info, and
+ /// cycle info as needed.
+ static BasicBlock *
+ createCallBrTarget(CallBrInst *CallBr, BasicBlock *Succ, unsigned SuccIdx,
+ CycleInfo *CI = nullptr, DomTreeUpdater *DTU = nullptr,
+ LoopInfo *LI = nullptr, bool *UpdatedLI = nullptr);
----------------
Meinersbur wrote:
Is this like [`llvm::SplitEdge`](https://github.com/llvm/llvm-project/blob/624d4f67549c0740e86293dab46b9be9291cdd4d/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h#L259)?
Consider moving it to `BasicBlockUtils.h` and a similar name such as `splitCallBrEdge`, or even reusing `SplitBlock`.
https://github.com/llvm/llvm-project/pull/149308
More information about the llvm-commits
mailing list