-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Dereferencing as reassignment target #5923
Conversation
Benchmark for fd7f2c7Click to view benchmark
|
Benchmark for 66646f7Click to view benchmark
|
Benchmark for d32779fClick to view benchmark
|
Benchmark for 3d17592Click to view benchmark
|
test/src/e2e_vm_tests/test_programs/should_fail/expression_cannot_be_assigned_to/test.toml
Show resolved
Hide resolved
Benchmark for 2722d9bClick to view benchmark
|
Benchmark for b76f699Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not yet had a chance to look through your tests, so I'm holding off on final approval. I've looked through all the code, though, and except for a couple of minor issues here and there everything looks sound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small but (I think) important mistake in one of the tests, but other than that the tests look fine.
test/src/e2e_vm_tests/test_programs/should_fail/array_bad_index/test.toml
Show resolved
Hide resolved
Benchmark for 4215a05Click to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR implements dereferencing in reassignment targets, as defined in references. The overall effort related to references is tracked in #5063.
Up to now, it was only possible to read the values references refer to. This PR allows values to be written over
&mut
references. In other words, any*<expression that results in &mut>
is now an l-values and can be used in left-hand sides (LHS) of assignments. In most of the cases, the<expression>
will very likely be just a reference variable, but any expression that results in&mut
is allowed and supported. E.g.;Additionally, the PR:
u64
.The PR also brings additional analysis and checks to IR optimizations. Among other things, it explicitly points out the cases in which a potential usage of a symbol cannot be deterministically confirmed or denied. In this PR properly reacting for such cases is done in some optimizations. Rolling it out fully will be done in a follow up PR #5924. More advanced escape analysis will be done later on, as a part of allocating values on the heap in case of referencing.
This PR implements only dereferencing in LHS. Support for referenced elements in the element based access (without dereferencing) will be done in a separate step as an ongoing work on implementing #5063.
Closes #5736, #5737, #5920, #5922.
Demo
Before:

After:

Expression cannot be assigned to:
Checklist
Breaking*
orNew Feature
labels where relevant.