[llvm] [mlir] [openmp] [mlir][llvmir][OpenMP] Translate affinity clause in task construct to llvmir (PR #182223)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 04:11:00 PDT 2026
================
@@ -11532,6 +11541,55 @@ void OpenMPIRBuilder::loadOffloadInfoMetadata(vfs::FileSystem &VFS,
loadOffloadInfoMetadata(*M.get());
}
+OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createIteratorLoop(
+ LocationDescription Loc, llvm::Value *TripCount, IteratorBodyGenTy BodyGen,
+ llvm::StringRef Name) {
+ Builder.restoreIP(Loc.IP);
+
+ BasicBlock *CurBB = Builder.GetInsertBlock();
+ assert(CurBB &&
+ "expected a valid insertion block for creating an iterator loop");
+ Function *F = CurBB->getParent();
+
+ InsertPointTy SplitIP = Builder.saveIP();
+ if (SplitIP.getPoint() == CurBB->end())
+ if (Instruction *Terminator = CurBB->getTerminator())
+ SplitIP = InsertPointTy(CurBB, Terminator->getIterator());
+
+ BasicBlock *ContBB =
+ splitBB(SplitIP, /*CreateBranch=*/false,
+ Builder.getCurrentDebugLocation(), "omp.it.cont");
+
+ CanonicalLoopInfo *CLI =
+ createLoopSkeleton(Builder.getCurrentDebugLocation(), TripCount, F,
+ /*PreInsertBefore=*/ContBB,
+ /*PostInsertBefore=*/ContBB, Name);
+
+ // Enter loop from original block.
+ redirectTo(CurBB, CLI->getPreheader(), Builder.getCurrentDebugLocation());
+
+ // Remove the unconditional branch inserted by createLoopSkeleton in the body
+ if (Instruction *T = CLI->getBody()->getTerminator())
+ T->eraseFromParent();
+
+ InsertPointTy BodyIP = CLI->getBodyIP();
+ if (llvm::Error Err = BodyGen(BodyIP, CLI->getIndVar()))
+ return Err;
----------------
tblah wrote:
`omp.yield` isn't converted into an llvm dialect terminator: see `OpenMPDialectLLVMTranslationInterface::convertOperation`.
https://github.com/llvm/llvm-project/pull/182223
More information about the llvm-commits
mailing list