[Mlir-commits] [mlir] 762ad00 - [mlir][gpu] Validate `gpu-module-to-binary` format (#182842)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Feb 23 20:55:03 PST 2026
Author: Akimasa Watanuki
Date: 2026-02-24T13:54:59+09:00
New Revision: 762ad000070fa30a318d187eb67058318dff026a
URL: https://github.com/llvm/llvm-project/commit/762ad000070fa30a318d187eb67058318dff026a
DIFF: https://github.com/llvm/llvm-project/commit/762ad000070fa30a318d187eb67058318dff026a.diff
LOG: [mlir][gpu] Validate `gpu-module-to-binary` format (#182842)
`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
Added:
mlir/test/Dialect/GPU/module-to-binary-invalid-format.mlir
Modified:
mlir/lib/Dialect/GPU/Transforms/ModuleToBinary.cpp
Removed:
################################################################################
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} {
+}
More information about the Mlir-commits
mailing list