[llvm-branch-commits] [clang] [llvm] [mlir] [MLIR][OpenMP] Add LLVM translation support for OpenMP UserDefinedMappers (PR #124746)

Sergio Afonso via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 11 05:51:00 PST 2025


================
@@ -9099,9 +9099,10 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
   CGM.getCXXABI().getMangleContext().mangleCanonicalTypeName(Ty, Out);
   std::string Name = getName({"omp_mapper", TyStr, D->getName()});
 
-  auto *NewFn = OMPBuilder.emitUserDefinedMapper(PrivatizeAndGenMapInfoCB,
-                                                 ElemTy, Name, CustomMapperCB);
-  UDMMap.try_emplace(D, NewFn);
+  llvm::Expected<llvm::Function *> NewFn = OMPBuilder.emitUserDefinedMapper(
+      PrivatizeAndGenMapInfoCB, ElemTy, Name, CustomMapperCB);
+  assert(NewFn && "Unexpected error in emitUserDefinedMapper");
----------------
skatrak wrote:

Wrap the call to `OMPBuilder.emitUserDefinedMapper` with `llvm::cantFail()` instead, which would consume and discard the error. Doing it with an assert has the problem that it will always crash if assertions are off, regardless of errors.

In clang, the error handling process involves early process exit during execution of the callback, which allows us to just assume there are no errors here. In MLIR to LLVM IR translation, however, we have to forward or handle errors so we can exit gracefully.

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


More information about the llvm-branch-commits mailing list