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(ssa refactor): recursive branch analysis #1759

Merged
merged 4 commits into from
Jun 20, 2023
Merged

Conversation

joss-aztec
Copy link
Contributor

@joss-aztec joss-aztec commented Jun 20, 2023

Description

Problem*

Resolves GH-1664

The existing implementation of analyze_function used a queue + stack-based approach to to associating a branch start with an end. I couldn't convince myself that there was a way to make this approach safe, so I've written a recursion-based alternative that passes the failing case surfaced by GH-1664.

Summary*

This alternative recursion based-approach associates a branch start to its end at the point that a recursion exits, such that the association is encapsulated. A disadvantage to this approach is that it does result in extra allocations, because visited hash sets and Steppers are allocated for each level of recursion.

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

PR Checklist*

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

@joss-aztec joss-aztec marked this pull request as ready for review June 20, 2023 11:10
@joss-aztec joss-aztec changed the title WIP: Joss/branch analysis fix(ssa refactor): recursive branch analysis Jun 20, 2023
@joss-aztec joss-aztec requested a review from jfecher June 20, 2023 11:10
Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

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

I went back and forth on this a little bit wondering if we could leverage an existing graph algorithm like Least Common Ancestor (with the edges reversed to find branch ends), but that wouldn't give use the list of in-between blocks. This change is also still fairly short so I think it is good to merge since it fixes the bug in question.

@jfecher jfecher added this pull request to the merge queue Jun 20, 2023
Merged via the queue into master with commit 635b574 Jun 20, 2023
@jfecher jfecher deleted the joss/branch_analysis branch June 20, 2023 23:26
This was referenced Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dom check panics
2 participants