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 a bug in the IR parsing. #2442

Merged
merged 2 commits into from Aug 2, 2022
Merged

Fix a bug in the IR parsing. #2442

merged 2 commits into from Aug 2, 2022

Conversation

otrho
Copy link
Contributor

@otrho otrho commented Aug 2, 2022

When resolving calls after recreating the IR from parsed input as a second pass the old code would inject a NOP where the CALL should go and replace it with a resolved CALL.

This was a problem when the call value was used as an argument to anothercall, as the NOP was taken rather than the CALL. Attempting to replace the NOP everywhere was very tricky (I couldn't actually manage it in the end).

A better (though still a bit hacky) approach now is to inject a CALL from the start, but to a dummy function and replace that function within the CALL in the resolving pass. This way any references to the call value are valid from the start.

When resolving calls after recreating the IR from parsed input as a
second pass the old code would inject a NOP where the CALL should go and
replace it with a resolved CALL.

This was a problem when the call value was used as an argument to another
call, as the NOP was taken rather than the CALL.  Attempting to replace
the NOP everywhere was very tricky (I couldn't actually manage it in the
end).

A better (though still a bit hacky) approach now is to inject a CALL
from the start, but to a dummy function and replace that function within
the CALL in the resolving pass.  This way any references to the call
value are valid from the start.
@otrho otrho added bug Something isn't working compiler: ir IRgen and sway-ir including optimization passes labels Aug 2, 2022
@otrho otrho requested a review from a team August 2, 2022 12:19
@otrho otrho self-assigned this Aug 2, 2022
@otrho otrho enabled auto-merge (squash) August 2, 2022 12:22
@otrho otrho merged commit 51a304e into master Aug 2, 2022
@otrho otrho deleted the otrho/ir-parser-bug branch August 2, 2022 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: ir IRgen and sway-ir including optimization passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants