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

Separate runtimes before SSA #6841

Closed
vezenovm opened this issue Dec 17, 2024 · 0 comments · Fixed by #6894
Closed

Separate runtimes before SSA #6841

vezenovm opened this issue Dec 17, 2024 · 0 comments · Fixed by #6894
Assignees
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request ssa

Comments

@vezenovm
Copy link
Contributor

Problem

We have two types of functions, ACIR and Brillig (constrained vs unconstrained). Brillig functions are simply marked with the unconstrained function modifier.

In Noir code, we allow ACIR functions to be called in the unconstrained environment. The goal was to reduce code duplication and the need to have the user write two different Noir functions for both constrained and unconstrained if they wanted to compute the same thing in both runtimes.

Right now, we separate runtimes during an SSA pass called runtime_separation. This converts any remaining functions with the Brillig runtime. If an ACIR function was called from the Brillig runtime, this pass will clone the function and change its runtime to Brillig. The pass is restricted to only work after defunctionalization.

We should move to have runtime separation occur during monomorphization in the frontend before SSA generation. This would enable us then to code gen different SSA based upon the runtime of a function such as #6231. Logic from other issues such as #6831 could also just be included as part of SSA generation as we will already know the runtime of the function we are generating.

Happy Case

We should be able to safely access function runtimes during SSA generation.

Workaround

Yes

Workaround Description

The workaround is to keep doing what we are doing and work with separated runtimes only after the runtime_separation pass. I find this generally will lead to more complexity.

Additional Context

No response

Project Impact

Blocker

Blocker Context

This work is a blocker for PR #6231. We could probably hack around not having the runtime during SSA gen, but it would be ugly and introduce a lot of complexity.

Would you like to submit a PR for this Issue?

None

Support Needs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request ssa
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants