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

fix: Implement new mem2reg pass #2420

Merged
merged 18 commits into from
Aug 25, 2023
Merged

fix: Implement new mem2reg pass #2420

merged 18 commits into from
Aug 25, 2023

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Aug 23, 2023

Description

Problem*

Resolves #2406
Resolves #2316
Resolves #2417

Summary*

Overhauls the mem2reg pass in the SSA to handle function calls and aliases.

There are some TODOs as part of this PR - I do not plan on implementing these as part of the PR and will create issues for them tomorrow. Most notable of them is that aliases within array values are not tracked.

I still need to write more documentation for this pass as well. It is missing much of the overall pass architecture documentation from the hackmd document linked in the issue. This PR is also currently missing additional test cases for the new features.

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

Note that in some tests, the expected number of stores that are removed has changed. The new pass will keep each store that is still possibly used as well as the final store in each block. This is because the final store may still be needed when another block is branched to afterward.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@jfecher
Copy link
Contributor Author

jfecher commented Aug 24, 2023

This PR is ready for review

Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

Nice, the documentation and code reads well. Mainly a couple nits and questions

crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Outdated Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Show resolved Hide resolved
crates/noirc_evaluator/src/ssa/opt/mem2reg.rs Show resolved Hide resolved
Copy link
Contributor

@vezenovm vezenovm left a comment

Choose a reason for hiding this comment

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

LGTM

@kevaundray kevaundray added this pull request to the merge queue Aug 25, 2023
Merged via the queue into master with commit 7714cd0 Aug 25, 2023
@kevaundray kevaundray deleted the jf/new-mem2reg branch August 25, 2023 18:42
TomAFrench added a commit that referenced this pull request Aug 25, 2023
* master:
  fix: Implement new mem2reg pass (#2420)
  feat(nargo): Support optional directory in git dependencies (#2436)
  fix(acir_gen): Pass accurate contents to slice inputs for bb func calls (#2435)
  fix(ssa): codegen missing check for unary minus (#2413)
  fix(lsp): Remove duplicated creation of lenses (#2433)
  feat: Add `test(should_fail)` attribute for tests that are meant to fail (#2418)
  chore: improve error message for InternalError (#2429)
  chore: Add stdlib to every crate as it is added to graph (#2392)
jfecher added a commit that referenced this pull request Aug 28, 2023
Co-authored-by: Maxim Vezenov <mvezenov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants