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

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 20 23:19:09 PDT 2025


================
@@ -1766,12 +1766,28 @@ void llvm::InvertBranch(BranchInst *PBI, IRBuilderBase &Builder) {
   PBI->swapSuccessors();
 }
 
-bool llvm::hasOnlySimpleTerminator(const Function &F) {
+template <typename... TermInst>
+bool llvm::hasOnlyGivenTerminators(const Function &F) {
   for (auto &BB : F) {
     auto *Term = BB.getTerminator();
-    if (!(isa<ReturnInst>(Term) || isa<UnreachableInst>(Term) ||
-          isa<BranchInst>(Term)))
+    if (!(isa<TermInst>(Term) || ...))
----------------
ssahasra wrote:

I don't fully understand how this works in C++ templates, but looking at the definition of `isa<>`, a simpler approach seems to be to pass that entire `...` bundle directly to isa, which can handle it, right?

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


More information about the llvm-commits mailing list