[Mlir-commits] [mlir] [mlir][gpu] Extend `mgpumoduleLoadJIT` API to add assemblySize parameter (PR #189429)

Fabian Mora llvmlistbot at llvm.org
Fri Apr 3 09:00:29 PDT 2026


================
@@ -520,10 +520,16 @@ extern "C" ze_module_handle_t mgpuModuleLoad(const void *data,
   return catchAll([&]() { return loadModule(data, gpuBlobSize); });
 }
 
-extern "C" ze_module_handle_t mgpuModuleLoadJIT(void *data, int optLevel) {
+extern "C" ze_module_handle_t mgpuModuleLoadJIT(void *data, int optLevel,
+                                                size_t assemblySize) {
+  // Account for extra null terminator added in embedBinaryImpl.
+  // A null terminator is added during embedding binary for assembly format to
+  // support JIT paths that expect null-terminated strings. However, for SPIR-V
+  // binary format, the null terminator is not expected. So we need to subtract
+  // the null terminator when loading SPIR-V binary.
----------------
fabianmcg wrote:

My only suggestion here is add an assertion like:
```C++
assert((assemblySize == 0 || reinterpret_cast<char*>(data)[assemblySize - 1] == 0) && "expected null-terminated string");
```

Otherwise, it might be hard to debug if anything changes.

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


More information about the Mlir-commits mailing list