-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add locations to most SSA instructions (#5697)
# Description ## Problem\* Resolves #5322 ## Summary\* Previously we added call stacks as a way to give better error reporting on SSA instructions. Since these were just for errors, they only needed to be on instructions which could emit errors. Since then, these call stacks have also been used for profiling Noir code which revealed many instructions without locations - many of them being instructions inserted by the compiler rather than the user during intermediate compiler passes like flatten_cfg. I've went through and gotten rid of each case of `CallStack::new()`. As far as I can tell all the remaining locations are either the intended use case of an initial, empty value, or are used in some error messages where the location is unknown. Anyways - because many of the instructions without locations were not introduced by the user I've had to decide which location best describes them. These instructions are largely internal compiler details so many users would be surprised if they knew e.g. we inserted extra `Store` instructions to _undo_ previous store instructions when going between an if expression's then and else branches. In this case, I set the location of this undo store instruction the same as the original store, but an argument could be made that it should actually be in the else branch or share location with the whole if expression. Similarly, when an `if` expression is used we merge the return value of the then & else branches to get the return value of the `if` expression itself. For these values I've opted to use the location of the entire `if` expression. ## Additional Context @vezenovm I think this covers all the work needed for this issue after all. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
12 changed files
with
184 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.