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

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 12:01:53 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)) {
----------------
Jason-VanBeusekom wrote:

I agree, guessing this has just been miscommunication on my end, with mixing up the cases:

Current commit has:

```c++
          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)))
            if (Device.RTL->data_submit(DeviceId, DeviceEntry.Address,
                                        Entry.Address,
                                        Entry.Size) != OFFLOAD_SUCCESS)
              REPORT("Failed to write symbol for USM %s\n", Entry.SymbolName);
```
In the original commit it was:

```c++
          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);
          }
```

For the other (above) case the original commit had:
```c++
 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);
```

Current commit has it as:

```c++
 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);
```
Which I believe we want to keep to avoid bundling with the error check.

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


More information about the llvm-commits mailing list