[flang-commits] [flang] [mlir] [OpenMP] Introduce omp.target_allocmem and omp.target_freemem omp dialect ops. (PR #145464)

via flang-commits flang-commits at lists.llvm.org
Fri Jul 25 04:34:53 PDT 2025


================
@@ -125,10 +125,177 @@ struct PrivateClauseOpConversion
     return mlir::success();
   }
 };
+
+static mlir::LLVM::LLVMFuncOp getOmpTargetAlloc(mlir::Operation *op) {
+  auto module = op->getParentOfType<mlir::ModuleOp>();
+  if (mlir::LLVM::LLVMFuncOp mallocFunc =
+          module.lookupSymbol<mlir::LLVM::LLVMFuncOp>("omp_target_alloc"))
+    return mallocFunc;
+  mlir::OpBuilder moduleBuilder(module.getBodyRegion());
+  auto i64Ty = mlir::IntegerType::get(module->getContext(), 64);
+  auto i32Ty = mlir::IntegerType::get(module->getContext(), 32);
+  return moduleBuilder.create<mlir::LLVM::LLVMFuncOp>(
+      moduleBuilder.getUnknownLoc(), "omp_target_alloc",
+      mlir::LLVM::LLVMFunctionType::get(
+          mlir::LLVM::LLVMPointerType::get(module->getContext()),
+          {i64Ty, i32Ty},
+          /*isVarArg=*/false));
+}
+
+static mlir::Type convertObjectType(const fir::LLVMTypeConverter &converter,
----------------
skc7 wrote:

Windows build is failing due to linker error if I move this function to Utils. Linux build is failing in debug mode locally aswell. So, moved this back here as a static utility function to avoid any extra linking libs to FIRSupport. 

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


More information about the flang-commits mailing list