[Openmp-commits] [llvm] [openmp] [OpenMP][Device] Fix __llvm_omp_indirect_call_lookup function pointer types (PR #192502)

via Openmp-commits openmp-commits at lists.llvm.org
Thu Apr 16 11:24:20 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: Nick Sarnie (sarnex)

<details>
<summary>Changes</summary>

`__llvm_omp_indirect_call_lookup` takes in and returns a function pointer, so make sure the types are correct, which includes the correct address space.

The FE was recently changed to generate the correct code [here](https://github.com/llvm/llvm-project/pull/192470).

With this change, three function pointer tests start passing.

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


4 Files Affected:

- (modified) offload/test/api/omp_indirect_call_table_manual.c (-1) 
- (modified) offload/test/api/omp_indirect_func_array.c (-1) 
- (modified) offload/test/api/omp_indirect_func_struct.c (-1) 
- (modified) openmp/device/src/Misc.cpp (+4-4) 


``````````diff
diff --git a/offload/test/api/omp_indirect_call_table_manual.c b/offload/test/api/omp_indirect_call_table_manual.c
index 550c9fc4d201c..1467cb6e93767 100644
--- a/offload/test/api/omp_indirect_call_table_manual.c
+++ b/offload/test/api/omp_indirect_call_table_manual.c
@@ -1,5 +1,4 @@
 // RUN: %libomptarget-compile-run-and-check-generic
-// XFAIL: intelgpu
 // REQUIRES: gpu
 #include <assert.h>
 #include <omp.h>
diff --git a/offload/test/api/omp_indirect_func_array.c b/offload/test/api/omp_indirect_func_array.c
index ba329ee034745..fa614f4f0fb6f 100644
--- a/offload/test/api/omp_indirect_func_array.c
+++ b/offload/test/api/omp_indirect_func_array.c
@@ -1,5 +1,4 @@
 // RUN: %libomptarget-compile-run-and-check-generic
-// XFAIL: intelgpu
 // REQUIRES: gpu
 
 #include <assert.h>
diff --git a/offload/test/api/omp_indirect_func_struct.c b/offload/test/api/omp_indirect_func_struct.c
index 2f885577f7c61..1937d2762b4e6 100644
--- a/offload/test/api/omp_indirect_func_struct.c
+++ b/offload/test/api/omp_indirect_func_struct.c
@@ -1,5 +1,4 @@
 // RUN: %libomptarget-compile-run-and-check-generic
-// XFAIL: intelgpu
 // REQUIRES: gpu
 
 #include <assert.h>
diff --git a/openmp/device/src/Misc.cpp b/openmp/device/src/Misc.cpp
index 158eac2f457c6..f31639a46da18 100644
--- a/openmp/device/src/Misc.cpp
+++ b/openmp/device/src/Misc.cpp
@@ -23,13 +23,13 @@ namespace impl {
 /// Lookup a device-side function using a host pointer /p HstPtr using the table
 /// provided by the device plugin. The table is an ordered pair of host and
 /// device pointers sorted on the value of the host pointer.
-static void *indirectCallLookup(void *HstPtr) {
+static FnPtrTy indirectCallLookup(FnPtrTy HstPtr) {
   if (!HstPtr)
     return nullptr;
 
   struct IndirectCallTable {
-    void *HstPtr;
-    void *DevPtr;
+    FnPtrTy HstPtr;
+    FnPtrTy DevPtr;
   };
   IndirectCallTable *Table =
       reinterpret_cast<IndirectCallTable *>(config::getIndirectCallTablePtr());
@@ -89,7 +89,7 @@ double omp_get_wtime(void) {
   return static_cast<double>(__builtin_readsteadycounter()) * omp_get_wtick();
 }
 
-void *__llvm_omp_indirect_call_lookup(void *HstPtr) {
+FnPtrTy __llvm_omp_indirect_call_lookup(FnPtrTy HstPtr) {
   return ompx::impl::indirectCallLookup(HstPtr);
 }
 

``````````

</details>


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


More information about the Openmp-commits mailing list