Skip to content

Commit efd4465

Browse files
authored
[Triton] Default diagnostic handler only filters for errors (#5173)
A regular SourceMgrDiagnosticHandler is causing all remarks to be emitted even if the user doesn't ask for it!
1 parent 1a1ad5e commit efd4465

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

python/src/ir.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,10 +1757,23 @@ void init_triton_ir(py::module &&m) {
17571757

17581758
// Run the pass manager under a source manager diagnostic handler, which
17591759
// enables emitted MLIR diagnostics to directly reference Python source
1760-
// code.
1761-
llvm::SourceMgr sourceMgr;
1762-
SourceMgrDiagnosticHandler diagHandler(sourceMgr, mod.getContext(),
1763-
llvm::errs());
1760+
// code. This diagnostic handler will only filter for errors.
1761+
struct SourceMgrErrorDiagnosticHandler
1762+
: public SourceMgrDiagnosticHandler {
1763+
SourceMgrErrorDiagnosticHandler(MLIRContext *ctx)
1764+
: SourceMgrDiagnosticHandler(sourceMgr, ctx, llvm::errs()) {
1765+
setHandler([this](Diagnostic &diag) {
1766+
if (diag.getSeverity() != DiagnosticSeverity::Error)
1767+
return failure();
1768+
emitDiagnostic(diag);
1769+
return success();
1770+
});
1771+
}
1772+
1773+
llvm::SourceMgr sourceMgr;
1774+
};
1775+
SourceMgrErrorDiagnosticHandler diagHandler(mod.getContext());
1776+
17641777
if (failed(self.run(mod.getOperation())))
17651778
throw std::runtime_error("PassManager::run failed");
17661779
});

0 commit comments

Comments
 (0)