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

Remove constants as explicit SSA values from IR serialisation. #2820

Open
otrho opened this issue Sep 21, 2022 · 2 comments
Open

Remove constants as explicit SSA values from IR serialisation. #2820

otrho opened this issue Sep 21, 2022 · 2 comments
Labels
compiler: ir IRgen and sway-ir including optimization passes enhancement New feature or request

Comments

@otrho
Copy link
Contributor

otrho commented Sep 21, 2022

When reading the printed IR it can get a bit verbose, as constants are always assigned to values. E.g.,

        v54 = const u64 3, !62
        v55 = const u64 2, !63
        v56 = const u64 1, !64
        v57 = call sum_test_13(v54, v55, v56), !54
        v58 = const u64 6, !65
        v59 = cmp eq v57 v58, !66

It's also a pain in the serialisation code itself. Each instruction which takes a value as an argument needs to be sure to print the argument first in case it's a constant, because constants themselves aren't instructions. E.g.,
https://github.com/FuelLabs/sway/blob/master/sway-ir/src/printer.rs#L510-L528

If we plan to remove non-copy-type constants as immediates (as even reference-type constants are still references) in #2819 it should be simpler and easier to read if we inline the constants, so the above code would become:

        v57 = call sum_test_13(const u64 3, const u64 2, const u64 1), !54
        v58 = cmp eq v57 const u64 6, !66
@otrho otrho added enhancement New feature or request compiler: ir IRgen and sway-ir including optimization passes labels Sep 21, 2022
@otrho
Copy link
Contributor Author

otrho commented Sep 30, 2022

If we plan to remove non-copy-type constants as immediates (as even reference-type constants are still references)

I did this in #2843 as they were getting allocated and leaked on the stack.

@vaivaswatha
Copy link
Contributor

Can be done as part of #4517.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: ir IRgen and sway-ir including optimization passes enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants