Skip to content

fix(ssa): Mark mutually recursive simple functions#8447

Merged
vezenovm merged 9 commits intomasterfrom
mv/mark-mutually-recursive-simple-funcs
May 12, 2025
Merged

fix(ssa): Mark mutually recursive simple functions#8447
vezenovm merged 9 commits intomasterfrom
mv/mark-mutually-recursive-simple-funcs

Conversation

@vezenovm
Copy link
Contributor

@vezenovm vezenovm commented May 12, 2025

Description

Problem*

Resolves #8414

We were not correctly checking for mutually recursive functions in inline_functions_with_at_most_one_instruction.

Summary*

I chose to lean into computing a full graph here as to push for re-use of the same call graph. As noted by #7228 we have multiple implementations of call graphs. Even though inline_functions_with_at_most_one_instruction should ideally only process functions with a single instruction, I felt leaning into a single call graph was better and simpler than expanding the inline_functions_with_at_most_one_instruction recursion check to account for mutual recursion cycles.

I went with using the call graph from opt::pure. I went with this graph as it uses petgraph. Using this crate simplifies our graph generation and provides nice utility methods out of the box such as fetching strongly connected components (SCC).

After generating the CallGraph we determine the recursive functions by checking the graph's SCCs.

Additional Context

I experimented with using the InlineInfo computation. This revealed that the call graph there is not appropriately marking recursive functions. I have captured an issue here #8448 and I have added a test with #[should_panic]. I will resolve this issue in a follow-up where the InlineInfo computation uses the same call graph as we use in this PR.

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 May 12, 2025 12:14
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: 77e5165 Previous: f8c6943 Ratio
test_report_noir-lang_noir_bigcurve_ 302 s 229 s 1.32

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

CC: @TomAFrench

Copy link
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

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

It's great to see general graph algorithms coming into action 👍

@vezenovm vezenovm enabled auto-merge May 12, 2025 13:49
@vezenovm vezenovm added this pull request to the merge queue May 12, 2025
Merged via the queue into master with commit 6d6aca9 May 12, 2025
116 checks passed
@vezenovm vezenovm deleted the mv/mark-mutually-recursive-simple-funcs branch May 12, 2025 14:29
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request May 13, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: sign extend in signed cast
(noir-lang/noir#8264)
chore(fuzz): Do not use zero length types in the main input output
(noir-lang/noir#8465)
chore: fix visibility issues in test suite
(noir-lang/noir#8454)
chore: blackbox functions for ssa intepreter
(noir-lang/noir#8375)
feat: improve bitshift codegen
(noir-lang/noir#8442)
fix(ssa): Mark mutually recursive simple functions
(noir-lang/noir#8447)
fix: Fix nested trait dispatch with associated types
(noir-lang/noir#8440)
chore: carry visibilities in monomorphized AST
(noir-lang/noir#8439)
chore(tests): Add regression for now passing test
(noir-lang/noir#8441)
chore: use human-readable bytecode in snapshots
(noir-lang/noir#8164)
chore: bump external pinned commits
(noir-lang/noir#8445)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <tech@aztecprotocol.com>
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.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

Development

Successfully merging this pull request may close these issues.

Compiler crash inlining simple mutually recursive functions

2 participants