[Frontend][Diagnostics] Improve emitting diagnostic information#5581
Merged
manman-ren merged 1 commit intotriton-lang:mainfrom Jan 30, 2025
Merged
Conversation
bd12964 to
205471f
Compare
Contributor
Author
|
Sorry for pinging you for review - I did a wrong merge on my branch. |
205471f to
eea3604
Compare
manman-ren
approved these changes
Jan 16, 2025
Collaborator
manman-ren
left a comment
There was a problem hiding this comment.
Thanks for cleaning up/restructuring! This PR looks good to me.
Mogball
approved these changes
Jan 23, 2025
36ddd87 to
2da49ad
Compare
Collaborator
|
This looks good to me! It seems to have a conflict, please resolve it.
|
058cb20 to
aaa0512
Compare
aaa0512 to
baa8365
Compare
makslevental
pushed a commit
to makslevental/triton
that referenced
this pull request
Feb 19, 2025
…on-lang#5581) ### Summary This PR enhances the current implementation for emitting diagnostic remarks by introducing a unified handler in `ir.cc`. This handler manages diagnostic information more effectively and disables the emission of IRs unless explicitly requested by the user. The `MLIR_ENABLE_DIAGNOSTICS` environment variable now controls all diagnostic emission settings, accepting one or more values from `{warnings, remarks, stacktraces, operations}`, separated by commas. Detailed usage instructions are available in the README. ### Background Previously, a new default LLVM `SourceManager` was configured in `nvidia/backend/compiler.py` to support remarks, applied in both `make_ttgir` and `make_llir`. However, a custom handler already existed in `ir.cc`, and a more robust design should extend this handler rather than create a new one. ### Changes - **Unified Handler**: Inspired by LLVM upstream [[PR 117669](https://github.com/llvm/llvm-project/pull/117669)](https://github.com/llvm/llvm-project/pull/117669), this PR implements a similar custom handler that supports various severity levels. The `MLIR_ENABLE_DIAGNOSTICS` environment variable now specifies the severity level: `warnings` for warnings and errors, and `remarks` for remarks, warnings, and errors. - **IR Emission Control**: By default, the MLIR diagnostic API emits IRs, which can clutter error messages or performance remarks. This PR suppresses IR emission unless explicitly enabled by the user, improving the readability of error messages and performance remarks. Users can specify `MLIR_ENABLE_DIAGNOSTICS=remarks,operations` to include IR operations in remarks. - **Stacktraces**: Previously, setting `MLIR_ENABLE_DIAGNOSTICS=1` enabled all diagnostic information with stacktraces. Now, the `stacktraces` parameter specifically enables stacktraces. For example, `MLIR_ENABLE_DIAGNOSTICS=remarks,operations,stacktraces` enables IR operations and stacktraces, displaying all remarks, warnings, and errors. - **Testing**: Updated existing Python tests to verify that combinations of operations and stacktraces are emitted successfully. ### Future Work - With the new handler in place, there is an opportunity to further enhance the readability of existing warnings and remarks. This will be a focus in future updates. # New contributor declaration - [x] I am not making a trivial change, such as fixing a typo in a comment. - [x] I have written a PR description following these [rules](https://cbea.ms/git-commit/#why-not-how). - [x] I have run `pre-commit run --from-ref origin/main --to-ref HEAD`. - Select one of the following. - [x] I have added tests. - `/python/test` for end-to-end tests - [ ] This PR does not need a test. - Select one of the following. - [x] I have not added any `lit` tests. - [ ] The `lit` tests I have added follow these [best practices](https://mlir.llvm.org/getting_started/TestingGuide/#filecheck-best-practices), including the "tests should be minimal" section. (Usually running Python code and using the instructions it generates is not minimal.)
This was referenced Apr 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the current implementation for emitting diagnostic remarks by introducing a unified handler in
ir.cc. This handler manages diagnostic information more effectively and disables the emission of IRs unless explicitly requested by the user. TheMLIR_ENABLE_DIAGNOSTICSenvironment variable now controls all diagnostic emission settings, accepting one or more values from{warnings, remarks, stacktraces, operations}, separated by commas. Detailed usage instructions are available in the README.Background
Previously, a new default LLVM
SourceManagerwas configured innvidia/backend/compiler.pyto support remarks, applied in bothmake_ttgirandmake_llir. However, a custom handler already existed inir.cc, and a more robust design should extend this handler rather than create a new one.Changes
Unified Handler: Inspired by LLVM upstream [PR 117669]([MLIR][mlir-opt] add support for disabling diagnostics llvm/llvm-project#117669), this PR implements a similar custom handler that supports various severity levels. The
MLIR_ENABLE_DIAGNOSTICSenvironment variable now specifies the severity level:warningsfor warnings and errors, andremarksfor remarks, warnings, and errors.IR Emission Control: By default, the MLIR diagnostic API emits IRs, which can clutter error messages or performance remarks. This PR suppresses IR emission unless explicitly enabled by the user, improving the readability of error messages and performance remarks. Users can specify
MLIR_ENABLE_DIAGNOSTICS=remarks,operationsto include IR operations in remarks.Stacktraces: Previously, setting
MLIR_ENABLE_DIAGNOSTICS=1enabled all diagnostic information with stacktraces. Now, thestacktracesparameter specifically enables stacktraces. For example,MLIR_ENABLE_DIAGNOSTICS=remarks,operations,stacktracesenables IR operations and stacktraces, displaying all remarks, warnings, and errors.Testing: Updated existing Python tests to verify that combinations of operations and stacktraces are emitted successfully.
Future Work
New contributor declaration
I am not making a trivial change, such as fixing a typo in a comment.
I have written a PR description following these
rules.
I have run
pre-commit run --from-ref origin/main --to-ref HEAD.Select one of the following.
/python/testfor end-to-end testsSelect one of the following.
littests.littests I have added follow these best practices,including the "tests should be minimal" section. (Usually running Python code
and using the instructions it generates is not minimal.)