Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IRDumper for Scala IR #9543

Merged
merged 2 commits into from
Mar 27, 2024
Merged

Add IRDumper for Scala IR #9543

merged 2 commits into from
Mar 27, 2024

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Mar 26, 2024

Pull Request Description

Debugging/inspecting/watching changes in the Scala IR has always been very tricky. The only way to do that, other than attaching the debugger and inspecting nested object structures, has been IR.pretty method, that is not useful for large IRs. This PR add an IRDumper utility class that dumps the IR into a GraphViz textual format that can be further processed by the dot program to generate, e.g., svg files from these IRs.

A simple example (dumped by IRDumper into a file that is processed with dot -O -Tsvg file):
fqn_end_tmp gv

Important Notes

  • GraphViz format is even simpler than JSON format.
  • No dependencies added, just 3 simple Java classes.
  • Dumping the IR is optional and not used anywhere, when desired, one can dump IRs for example from Compiler.runPipeline

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@Akirathan Akirathan self-assigned this Mar 26, 2024
@Akirathan Akirathan marked this pull request as ready for review March 26, 2024 10:57
@Akirathan Akirathan mentioned this pull request Mar 26, 2024
5 tasks
@Akirathan Akirathan added the CI: No changelog needed Do not require a changelog entry for this PR. label Mar 26, 2024
@enso-bot enso-bot bot mentioned this pull request Mar 26, 2024
@Akirathan Akirathan added the CI: Ready to merge This PR is eligible for automatic merge label Mar 27, 2024
Copy link
Contributor

@4e6 4e6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move the code to a separate SBT project. Otherwise, it looks good to me

@mergify mergify bot merged commit 76061e1 into develop Mar 27, 2024
42 checks passed
@mergify mergify bot deleted the wip/akirathan/ir-dumper branch March 27, 2024 09:19
@hubertp
Copy link
Contributor

hubertp commented Mar 27, 2024

I'd move the code to a separate SBT project. Otherwise, it looks good to me

Yes, maybe it should reside in tools?

@Akirathan
Copy link
Member Author

I'd move the code to a separate SBT project. Otherwise, it looks good to me

@4e6 @hubertp I don't think this is a viable option for now. This tool (a single class) is meant to be used inside the runtime-compiler project, for example from Compiler.runCompilerPipeline or inside PassManager to dump graphs after every IR pass. It is not really a standalone tool.

@JaroslavTulach
Copy link
Member

I believe that having this output in the IGV format would allow us to compare individual pipeline steps more easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants