[Mlir-commits] [mlir] [mlir][gpu] Validate `gpu-module-to-binary` format (PR #182842)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Feb 23 04:50:00 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-gpu
Author: Akimasa Watanuki (Men-cotton)
<details>
<summary>Changes</summary>
`GpuModuleToBinaryPass::runOnOperation` now treats an unsupported `format` value as a pass failure after emitting `"Invalid format specified."`.
Add a regression test in `mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir`.
Fix: https://github.com/llvm/llvm-project/issues/77052
Fix: https://github.com/llvm/llvm-project/issues/116344
Fix: https://github.com/llvm/llvm-project/issues/116346
Fix: https://github.com/llvm/llvm-project/issues/116352
---
Full diff: https://github.com/llvm/llvm-project/pull/182842.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp (+3-1)
- (added) mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir (+5)
``````````diff
diff --git a/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp b/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp
index e359b8620b4ea..1452c67021c30 100644
--- a/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp
@@ -44,8 +44,10 @@ void GpuModuleToBinaryPass::runOnOperation() {
.Cases({"binary", "bin"}, CompilationTarget::Binary)
.Cases({"fatbinary", "fatbin"}, CompilationTarget::Fatbin)
.Default(std::nullopt);
- if (!targetFormat)
+ if (!targetFormat) {
getOperation()->emitError() << "Invalid format specified.";
+ return signalPassFailure();
+ }
// Lazy symbol table builder callback.
std::optional<SymbolTable> parentTable;
diff --git a/mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir b/mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir
new file mode 100644
index 0000000000000..eb2c6dbc2be3f
--- /dev/null
+++ b/mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir
@@ -0,0 +1,5 @@
+// RUN: mlir-opt %s --gpu-module-to-binary="format=invalid-format" --verify-diagnostics
+
+// expected-error @+1 {{Invalid format specified.}}
+module attributes {gpu.container_module} {
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/182842
More information about the Mlir-commits
mailing list