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

Mehdi Amini llvmlistbot at llvm.org
Mon Dec 1 05:13:47 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();
----------------
joker-eph wrote:

I may have objections with the change depending on how it looks, I'm not convinced that these should be failable conceptually (in terms of what these APIs are meant to provide).

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


More information about the Mlir-commits mailing list