[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 03:47:46 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:
> How does the pass knows if ModuleToObject succeeds?
ModuleToObject isn't failable right now, but I'm failing to link the question to the current discussion actually?
> Also, in a frail system (take at least disk almost full, low ram, SWAP full...), the initial callback can fail, put the system in a an even more fragile state. Since ModuleToObject never became aware, it will continue, create some temp files (both NVVM and ROCDL targets create files), and fail again, but with a higher potential to crash, and it will be harder to debug where the problem started.
I don't quite see a concern with this, LLVM isn't resilient to system issues such as "swap filing up" or "machine running out of memory" in general.
https://github.com/llvm/llvm-project/pull/170016
More information about the Mlir-commits
mailing list