================ @@ -3529,6 +3549,86 @@ static void genMapInfos(llvm::IRBuilderBase &builder, } } +static llvm::Expected<llvm::Function *> +emitUserDefinedMapper(Operation *declMapperOp, llvm::IRBuilderBase &builder, + LLVM::ModuleTranslation &moduleTranslation); + +static llvm::Expected<llvm::Function *> +getOrCreateUserDefinedMapperFunc(Operation *op, llvm::IRBuilderBase &builder, + LLVM::ModuleTranslation &moduleTranslation) { + auto declMapperOp = cast<omp::DeclareMapperOp>(op); + std::string mapperFuncName = + moduleTranslation.getOpenMPBuilder()->createPlatformSpecificName( + {"omp_mapper", declMapperOp.getSymName()}); + if (auto *lookupFunc = moduleTranslation.lookupFunction(mapperFuncName)) + return lookupFunc; + + llvm::Expected<llvm::Function *> mapperFunc = + emitUserDefinedMapper(declMapperOp, builder, moduleTranslation); + if (!mapperFunc) + return mapperFunc.takeError(); + moduleTranslation.mapFunction(mapperFuncName, *mapperFunc); ---------------- skatrak wrote:
I think this should be moved to `emitUserDefinedMapper`. Even though it looks unlikely that there would be any callers to that function from anywhere else, I think the right place to register the new function is where it's created. That way, this can also be simplified by returning directly the result of the `emitUserDefinedMapper` call. https://github.com/llvm/llvm-project/pull/124746 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits