[llvm] [AMDGPU][FixIrreducible][UnifyLoopExits] Support callbr with inline-asm (PR #149308)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 03:56:44 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);
----------------
ro-i wrote:
I'm not sure if the interface is generic enough? It's specifically crafted to add the intermediate callbr target blocks in the context of the control flow hub, where it's important that the cycle and loop info is updated as it's done by `updateCycleLoopInfo`
https://github.com/llvm/llvm-project/pull/149308
More information about the llvm-commits
mailing list