[Openmp-commits] [clang] [llvm] [openmp] [OpenMP][clang] Indirect and Virtual function call mapping from host to device (PR #159857)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Oct 1 11:22:50 PDT 2025


================
@@ -6583,6 +6583,26 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType,
         Address(Handle, Handle->getType(), CGM.getPointerAlign()));
     Callee.setFunctionPointer(Stub);
   }
+
+  // Check whether the associated CallExpr is in the set OMPTargetCalls.
+  // If YES, insert a call to devicertl function __llvm_omp_indirect_call_lookup
+  //
+  // This is used for the indriect function Case, virtual function case is
+  // handled in ItaniumCXXABI.cpp
+  if (getLangOpts().OpenMPIsTargetDevice && CGM.OMPTargetCalls.contains(E)) {
+    auto *PtrTy = CGM.VoidPtrTy;
+    llvm::Type *RtlFnArgs[] = {PtrTy};
+    llvm::FunctionCallee DeviceRtlFn = CGM.CreateRuntimeFunction(
+        llvm::FunctionType::get(PtrTy, RtlFnArgs, false),
+        "__llvm_omp_indirect_call_lookup");
----------------
Jason-VanBeusekom wrote:

In https://github.com/llvm/llvm-project/pull/159857/commits/11b1f086b43736f07dd23313c474fab8a8e7e3e2 I changed the name to `__kmpc_omp_indirect_call_lookup`. The name `__llvm_omp_indirect_call_lookup` was originally created here: https://github.com/llvm/llvm-project/commit/aa78e94b0bc66375de7f2383b4e39c07cd482104

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


More information about the Openmp-commits mailing list