[llvm] [AMDGPU][FixIrreducible][UnifyLoopExits] Support callbr with inline-asm (PR #149308)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 29 06:57:32 PDT 2025


================
@@ -79,6 +79,53 @@
 // Limitation: The pass cannot handle switch statements and indirect
 //             branches. Both must be lowered to plain branches first.
 //
+// CallBr support: CallBr is handled as a more general branch instruction which
+// can have multiple successors. The pass redirects the edges to intermediate
+// target blocks that unconditionally branch to the original callbr target
+// blocks. This allows the control flow hub to know to which of the original
+// target blocks to jump to.
+// Example input CFG:
+//                        Entry (callbr)
+//                       /     \
+//                      v       v
+//                      H ----> B
+//                      ^      /|
+//                       `----' |
+//                              v
+//                             Exit
+//
+// becomes:
+//                        Entry (callbr)
+//                       /     \
+//                      v       v
+//                 target.H   target.B
+//                      |       |
+//                      v       v
+//                      H ----> B
+//                      ^      /|
+//                       `----' |
+//                              v
+//                             Exit
----------------
Meinersbur wrote:

Sounds exactly like what `SplitEdge` is doing. The only complicated case is the one of critical edges, otherwise `SplitEdge` is identical to splitting the predecessor or successor block. For normalzing the CFG, splitting may not be necessary except for critical edges.

https://github.com/llvm/llvm-project/pull/149308


More information about the llvm-commits mailing list