Skip to content

[flang][cuda][NFC] Add some diagnostic when module or fct are not found #119277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

clementval
Copy link
Contributor

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

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Dec 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 9, 2024

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/119277.diff

1 Files Affected:

  • (modified) flang/lib/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.cpp (+4)
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(),

@clementval clementval merged commit 650e736 into llvm:main Dec 10, 2024
11 checks passed
@clementval clementval deleted the cuf_translation_assert branch December 10, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants