[clang] [llvm] [mlir] [flang][OpenMP] Support `target enter|update|exit .. nowait` (PR #113305)

Kareem Ergawy via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 23 00:24:54 PDT 2024


================
@@ -6403,16 +6401,45 @@ OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::createTargetData(
       SrcLocInfo = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
     }
 
-    Value *OffloadingArgs[] = {SrcLocInfo,           DeviceID,
-                               PointerNum,           RTArgs.BasePointersArray,
-                               RTArgs.PointersArray, RTArgs.SizesArray,
-                               RTArgs.MapTypesArray, RTArgs.MapNamesArray,
-                               RTArgs.MappersArray};
+    SmallVector<llvm::Value *, 13> OffloadingArgs = {
+        SrcLocInfo,           DeviceID,
+        PointerNum,           RTArgs.BasePointersArray,
+        RTArgs.PointersArray, RTArgs.SizesArray,
+        RTArgs.MapTypesArray, RTArgs.MapNamesArray,
+        RTArgs.MappersArray};
 
     if (IsStandAlone) {
       assert(MapperFunc && "MapperFunc missing for standalone target data");
-      Builder.CreateCall(getOrCreateRuntimeFunctionPtr(*MapperFunc),
-                         OffloadingArgs);
+
+      auto TaskBodyCB = [&](Value *, Value *, IRBuilderBase::InsertPoint) {
+        if (Info.HasNoWait) {
+          OffloadingArgs.push_back(llvm::Constant::getNullValue(Int32));
+          OffloadingArgs.push_back(llvm::Constant::getNullValue(VoidPtr));
+          OffloadingArgs.push_back(llvm::Constant::getNullValue(Int32));
+          OffloadingArgs.push_back(llvm::Constant::getNullValue(VoidPtr));
+        }
+
+        Builder.CreateCall(getOrCreateRuntimeFunctionPtr(*MapperFunc),
+                           OffloadingArgs);
+
+        if (Info.HasNoWait) {
+          BasicBlock *OffloadContBlock =
+              BasicBlock::Create(Builder.getContext(), "omp_offload.cont");
+          auto *CurFn = Builder.GetInsertBlock()->getParent();
+          emitBranch(OffloadContBlock);
+          emitBlock(OffloadContBlock, CurFn, /*IsFinished=*/true);
----------------
ergawy wrote:

Seems like `emitBlock` is enough indeed. Let's see if the CI objects.

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


More information about the cfe-commits mailing list