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

Copy arrays in the SSA IR #1416

Closed
Tracked by #1376
jfecher opened this issue May 26, 2023 · 0 comments · Fixed by #1578
Closed
Tracked by #1376

Copy arrays in the SSA IR #1416

jfecher opened this issue May 26, 2023 · 0 comments · Fixed by #1578
Labels
enhancement New feature or request refactor ssa

Comments

@jfecher
Copy link
Contributor

jfecher commented May 26, 2023

Problem

Arrays in noir have value semantics. When passed to a function, they should have no observable change after the function call, even if the function being called internally mutates the array that it was passed as a parameter. Currently however, arrays are essentially passed as reference in the SSA IR and any mutations would be observable.

Happy Case

We should copy each array before passing them to any function call.

This could create many excess instructions even if a function only needs to mutate a single element of the array. If these cannot be avoided, we should create an issue to optimize this in the future to avoid these unnecessary instructions by e.g. analyzing which indices are mutated by the called function before copying the array. This would let us copy only the necessary indices.

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added the enhancement New feature or request label May 26, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir May 26, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor ssa
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant