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): Unused functions removals post folding constant Brillig calls #7265

Conversation

vezenovm
Copy link
Contributor

@vezenovm vezenovm commented Feb 3, 2025

Description

Problem*

Silly bug leftover from #7260, but also fixes this removal pass to be more accurate. We are not checking the full new call graph of unused functions.

e.g. for the following SSA:

        g0 = Field 2

        acir(inline) fn main f0 {
          b0():
            v1 = call f1() -> Field
            return v1
        }

        brillig(inline) fn entry_point f1 {
          b0():
            v1 = call f2() -> Field
            return v1
        }

        brillig(inline) fn one f2 {
          b0():
            v1 = add g0, Field 3
            return v1
        }

After constant folding we would still have:

        brillig(inline) fn one f2 {
          b0():
            v1 = add g0, Field 3
            return v1
        }

even though it would be unused. This is because we would only inline Brillig calls for ACIR entry points. Thus, we would still have a call to f2, even though f1 is now unused, thus f2 is also unused.

Summary*

I simply moved to using our pre-existing remove_unreachable_functions pass. I felt this kept a better separation of concerns for the passes and was a more complete removal of unreachable functions.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

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

@vezenovm vezenovm requested a review from a team February 3, 2025 18:59
vezenovm added a commit to AztecProtocol/aztec-packages that referenced this pull request Feb 3, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 152052b Previous: 0b6c382 Ratio
noir-lang_schnorr_ 1 s 0 s +∞
noir-lang_noir_check_shuffle_ 1 s 0 s +∞
noir-lang_noir_base64_ 2 s 1 s 2
noir-lang_eddsa_ 2 s 1 s 2
noir-lang_ec_ 1 s 0 s +∞

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Collaborator

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Makes sense and looks good!

@vezenovm vezenovm added this pull request to the merge queue Feb 4, 2025
Merged via the queue into master with commit d5d6cb7 Feb 4, 2025
101 checks passed
@vezenovm vezenovm deleted the mv/better-unreachable-funcs-removal-post-inlining-brillig-calls branch February 4, 2025 09:28
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.

2 participants