Skip to content

Commit

Permalink
[Triton] Default diagnostic handler only filters for errors (#5173)
Browse files Browse the repository at this point in the history
A regular SourceMgrDiagnosticHandler is causing all remarks to be
emitted even if the user doesn't ask for it!
  • Loading branch information
Mogball authored Nov 15, 2024
1 parent 1a1ad5e commit efd4465
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions python/src/ir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1757,10 +1757,23 @@ void init_triton_ir(py::module &&m) {

// Run the pass manager under a source manager diagnostic handler, which
// enables emitted MLIR diagnostics to directly reference Python source
// code.
llvm::SourceMgr sourceMgr;
SourceMgrDiagnosticHandler diagHandler(sourceMgr, mod.getContext(),
llvm::errs());
// code. This diagnostic handler will only filter for errors.
struct SourceMgrErrorDiagnosticHandler
: public SourceMgrDiagnosticHandler {
SourceMgrErrorDiagnosticHandler(MLIRContext *ctx)
: SourceMgrDiagnosticHandler(sourceMgr, ctx, llvm::errs()) {
setHandler([this](Diagnostic &diag) {
if (diag.getSeverity() != DiagnosticSeverity::Error)
return failure();
emitDiagnostic(diag);
return success();
});
}

llvm::SourceMgr sourceMgr;
};
SourceMgrErrorDiagnosticHandler diagHandler(mod.getContext());

if (failed(self.run(mod.getOperation())))
throw std::runtime_error("PassManager::run failed");
});
Expand Down

0 comments on commit efd4465

Please sign in to comment.