[Mlir-commits] [mlir] [mlir][gpu] `gpu-module-to-binary`: add option to dump intermediate files (PR #170016)

Fabian Mora llvmlistbot at llvm.org
Mon Dec 1 03:01:19 PST 2025


================
@@ -92,44 +90,52 @@ void GpuModuleToBinaryPass::runOnOperation() {
   for (const std::string &path : linkFiles)
     librariesToLink.push_back(StringAttr::get(&getContext(), path));
 
+  Operation *op = getOperation();
+
   // Create dump directory if specified.
   if (!dumpIntermediates.empty()) {
     if (std::error_code ec =
             llvm::sys::fs::create_directories(dumpIntermediates)) {
-      getOperation()->emitError() << "Failed to create dump directory '"
-                                  << dumpIntermediates << "': " << ec.message();
+      op->emitError() << "Failed to create dump directory '"
+                      << dumpIntermediates << "': " << ec.message();
       return signalPassFailure();
     }
   }
 
   // Create callbacks for dumping intermediate artifacts if requested.
   auto initialIRCallback = [&](llvm::Module &mod) {
-    dumpToFile(dumpIntermediates, mod.getName() + ".initial.ll",
-               [&](llvm::raw_ostream &os) { mod.print(os, nullptr); });
+    if (failed(
+            dumpToFile(op, dumpIntermediates, mod.getName() + ".initial.ll",
+                       [&](llvm::raw_ostream &os) { mod.print(os, nullptr); })))
+      signalPassFailure();
----------------
fabianmcg wrote:

Either we make callbacks always successful, ie. no `signalPassFailure()`, or we need to make callbacks return a LogicalResult and update everywhere, eg. https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/GPU/IR/CompilationInterfaces.h#L130-L133 

IMO it's better making them return a LogicalResult.

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


More information about the Mlir-commits mailing list