[llvm] [OpenMP][clang] Register vtables on device for indirect calls runtime (PR #167011)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 10:56:54 PST 2025


================
@@ -434,23 +434,23 @@ static int loadImagesOntoDevice(DeviceTy &Device) {
 
         llvm::offloading::EntryTy DeviceEntry = Entry;
         if (Entry.Size) {
-          if (!(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT_VTABLE) &&
-              Device.RTL->get_global(Binary, Entry.Size, Entry.SymbolName,
-                                     &DeviceEntry.Address) != OFFLOAD_SUCCESS)
-            REPORT("Failed to load symbol %s\n", Entry.SymbolName);
+          if (!(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT_VTABLE))
+            if (Device.RTL->get_global(Binary, Entry.Size, Entry.SymbolName,
+                                       &DeviceEntry.Address) != OFFLOAD_SUCCESS)
+              REPORT("Failed to load symbol %s\n", Entry.SymbolName);
 
           // If unified memory is active, the corresponding global is a device
           // reference to the host global. We need to initialize the pointer on
           // the device to point to the memory on the host.
-          if ((PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY) ||
-              (PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY)) {
-            if (!(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT_VTABLE) &&
-                !(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT) &&
-                Device.RTL->data_submit(DeviceId, DeviceEntry.Address,
-                                        Entry.Address,
-                                        Entry.Size) != OFFLOAD_SUCCESS)
-              REPORT("Failed to write symbol for USM %s\n", Entry.SymbolName);
-          }
+          if (!(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT_VTABLE) &&
+              !(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT))
+            if ((PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY) ||
+                (PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY)) {
----------------
jhuber6 wrote:

```suggestion
          if (!(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT_VTABLE) &&
              !(Entry.Flags & OMP_DECLARE_TARGET_INDIRECT) &&
               ((PM->getRequirements() & OMP_REQ_UNIFIED_SHARED_MEMORY) ||
               (PM->getRequirements() & OMPX_REQ_AUTO_ZERO_COPY))) {
```
Am I missing something? Why can't we just do something like this and above?

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


More information about the llvm-commits mailing list