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

Improve IR printing CLI in forc #6025

Merged
merged 1 commit into from
May 17, 2024
Merged

Conversation

ironcev
Copy link
Member

@ironcev ironcev commented May 16, 2024

Description

This PR:

  • implements detailed control over printing of IR:
    • initial IR
    • IR after choosen optimization steps, with option to print only the steps that have actually modified the IR
    • final IR
  • improves printed IRs by removing the confusing empty modules printed for every external library dependency.
  • harmonizes names and descriptions of the optimization passes. The proposed convention is documented in the sway-ir/src/optimize/README.md file.
  • harmonizes help comments of the shared compiler options (consistent separation between option title and additional info, wording, etc.)

Demo

'Print initial and final IR together with IR after each optimization step.
--ir all

'Print initial and final IR together with IR after each optimization step that has modified the IR.
--ir all modified

'Print only the final IR.
--ir final

'Print the IR after every "dce", "sroa", and "inline" optimization step.
--ir dce sroa inline

'Print the IR after every "dce", "sroa", and "inline" optimization step that has modified the IR.
--ir dce sroa inline modified

Breaking Changes

CLI

Instead of the existing --ir option without parameters we now have the same CLI option but with parameters. The existing --ir is equivalent to the new --ir final.

Build Profile

Instead of the existing print-ir of type bool, we now have the same print-ir build profile option with parameters. E.g.:

print-ir = { initial = true, final = false, modified = true, passes = ["dce", "sroa"]}

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this May 16, 2024
@ironcev ironcev added forc breaking May cause existing user code to break. Requires a minor or major release. forc-pkg Everything related to the `forc-pkg` crate. testing General testing labels May 16, 2024
@ironcev ironcev marked this pull request as ready for review May 16, 2024 22:21
@ironcev ironcev requested a review from kayagokalp as a code owner May 16, 2024 22:21
@ironcev ironcev requested review from vaivaswatha and a team and removed request for kayagokalp May 16, 2024 22:21
@ironcev ironcev enabled auto-merge (squash) May 16, 2024 22:24
Copy link

Benchmark for c0b8b76

Click to view benchmark
Test Base PR %
code_action 5.2±0.03ms 5.4±0.10ms +3.85%
code_lens 281.7±5.55ns 284.1±12.00ns +0.85%
compile 2.9±0.04s 2.9±0.03s 0.00%
completion 4.6±0.11ms 4.7±0.11ms +2.17%
did_change_with_caching 2.8±0.06s 2.8±0.04s 0.00%
document_symbol 1008.7±32.38µs 962.0±17.65µs -4.63%
format 70.1±1.15ms 70.1±0.87ms 0.00%
goto_definition 378.3±5.38µs 370.1±6.84µs -2.17%
highlight 8.7±0.20ms 9.0±0.22ms +3.45%
hover 496.9±7.46µs 491.0±8.26µs -1.19%
idents_at_position 123.2±0.33µs 122.9±1.20µs -0.24%
inlay_hints 680.6±55.04µs 668.4±22.87µs -1.79%
on_enter 459.6±13.44ns 480.8±15.74ns +4.61%
parent_decl_at_position 3.6±0.06ms 3.7±0.03ms +2.78%
prepare_rename 372.3±8.08µs 368.9±9.02µs -0.91%
rename 9.3±0.17ms 9.7±0.28ms +4.30%
semantic_tokens 973.9±11.73µs 981.9±12.82µs +0.82%
token_at_position 363.1±2.51µs 362.8±13.13µs -0.08%
tokens_at_position 3.6±0.08ms 3.7±0.06ms +2.78%
tokens_for_file 426.1±2.37µs 433.7±16.03µs +1.78%
traverse 39.9±0.66ms 40.6±1.11ms +1.75%

Copy link
Member

@kayagokalp kayagokalp left a comment

Choose a reason for hiding this comment

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

Tooling side looks good to me!

@kayagokalp kayagokalp requested a review from a team May 16, 2024 22:53
@ironcev ironcev merged commit 8c999fa into master May 17, 2024
42 checks passed
@ironcev ironcev deleted the ironcev/improve-ir-compiler-flag branch May 17, 2024 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking May cause existing user code to break. Requires a minor or major release. forc forc-pkg Everything related to the `forc-pkg` crate. testing General testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants