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

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


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

`__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.

>From 38741bee4618fc5085f6ca1836840f88a6c37495 Mon Sep 17 00:00:00 2001
From: Nick Sarnie <nick.sarnie at intel.com>
Date: Thu, 16 Apr 2026 11:18:05 -0700
Subject: [PATCH] [OpenMP][Device] Fix __llvm_omp_indirect_call_lookup function
 pointer type

Signed-off-by: Nick Sarnie <nick.sarnie at intel.com>
---
 offload/test/api/omp_indirect_call_table_manual.c | 1 -
 offload/test/api/omp_indirect_func_array.c        | 1 -
 offload/test/api/omp_indirect_func_struct.c       | 1 -
 openmp/device/src/Misc.cpp                        | 8 ++++----
 4 files changed, 4 insertions(+), 7 deletions(-)

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);
 }
 



More information about the Openmp-commits mailing list