[llvm] [OFFLOAD] Add interface to extend image validation (PR #185663)

Alex Duran via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:53:22 PDT 2026


================
@@ -1367,6 +1364,24 @@ struct GenericPluginTy {
   virtual Expected<bool> isELFCompatible(uint32_t DeviceID,
                                          StringRef Image) const = 0;
 
+  /// Indicate if an image is compatible with the plugin. This is called if
+  /// the image is not recognized as compatible by the common layer. This gives
+  /// the plugin a chance to inspect the image and decide if it is compatible.
+  virtual Expected<bool> isImageCompatible(StringRef Image) const {
+    return false;
+  }
+
+  /// Indicate if an imaget is compatible with the plugin devices. This is
+  /// called if the image is not recognized as compatible by the common layer.
+  /// This gives the plugin a chance to inspect the image and decide if it is
+  /// compatible. Notice that this function may be called before actually
+  /// initializing the devices. So we could not move this function into
+  /// GenericDeviceTy.
+  virtual Expected<bool> isImageCompatible(uint32_t DeviceID,
+                                           StringRef Image) const {
+    return isImageCompatible(Image);
----------------
adurang wrote:

That's our current design, we have isPluginCompatible (which would use the first one) and isDeviceCompatible (which would use the second one).

AFAICS no plugin does anything special taking into account the DeviceId but I guess the assumption is that potentially you might have an image that can only run on some the supported devices and this would allow for such check.

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


More information about the llvm-commits mailing list