[flang-commits] [flang] [flang][cuda][NFC] Add some diagnostic when module or fct are not found (PR #119277)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Mon Dec 9 14:02:44 PST 2024


https://github.com/clementval created https://github.com/llvm/llvm-project/pull/119277

Add some proper error if module or function are not found. 

>From 7f9d96f30ff18e024594d10040034c15d3562ced Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 9 Dec 2024 13:59:03 -0800
Subject: [PATCH] [flang][cuda][NFC] Add some diagnostic when module or fct are
 not found

---
 flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp
index 63eac46a997718..0c1424d11b515c 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp
@@ -66,8 +66,12 @@ LogicalResult registerKernel(cuf::RegisterKernelOp op,
       llvm::FunctionType::get(
           ptrTy, ArrayRef<llvm::Type *>({ptrTy, ptrTy, ptrTy}), false));
   llvm::Value *modulePtr = moduleTranslation.lookupValue(op.getModulePtr());
+  if (!modulePtr)
+    return op.emitError() << "Couldn't find the module ptr";
   llvm::Function *fctSym =
       moduleTranslation.lookupFunction(op.getKernelName().str());
+  if (!fctSym)
+    return op.emitError() << "Couldn't find kernel name symbol";
   builder.CreateCall(fct, {modulePtr, fctSym,
                            getOrCreateFunctionName(
                                module, builder, op.getKernelModuleName().str(),



More information about the flang-commits mailing list