-
Notifications
You must be signed in to change notification settings - Fork 4
feat(rt): handle zero-sized locals #809
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
Changes from 3 commits
fc12dcc
389add9
6571f0a
94f30cc
b6736e2
32e3bb1
0e8c30a
497f3e7
1c52f87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,13 @@ Constant operands are simply decoded according to their type. | |
| ... | ||
| </k> | ||
| requires typeInfoVoidType =/=K lookupTy(TY) | ||
|
|
||
| // Fallback for zero-sized constants whose type metadata was not emitted. | ||
| rule <k> operandConstant(constOperand(_, _, mirConst(constantKindZeroSized, TY, _))) | ||
| => Aggregate(variantIdx(0), .List) | ||
| ... | ||
| </k> | ||
| requires typeInfoVoidType ==K lookupTy(TY) | ||
| ``` | ||
|
|
||
| ### Copying and Moving | ||
|
|
@@ -1088,6 +1095,18 @@ This eliminates any `Deref` projections from the place, and also resolves `Index | |
| // rule #projectionsFor(CtxPointerOffset(OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, projectionElemSubslice(OFFSET, ORIGIN_LENGTH, false) PROJS) | ||
| rule #projectionsFor(CtxPointerOffset( _, OFFSET, ORIGIN_LENGTH) CTXS, PROJS) => #projectionsFor(CTXS, PointerOffset(OFFSET, ORIGIN_LENGTH) PROJS) | ||
|
|
||
| // Borrowing a zero-sized local that is still `NewLocal`: initialise it, then reuse the regular rule. | ||
| rule <k> rvalueRef(REGION, KIND, place(local(I), PROJS)) | ||
| => #forceSetLocal(local(I), Aggregate(variantIdx(0), .List)) | ||
| ~> rvalueRef(REGION, KIND, place(local(I), PROJS)) | ||
| ... | ||
| </k> | ||
| <locals> LOCALS </locals> | ||
| requires 0 <=Int I andBool I <Int size(LOCALS) | ||
| andBool isNewLocal(LOCALS[I]) | ||
| andBool #zeroSizedType(lookupTy(tyOfLocal(getLocal(LOCALS, I)))) | ||
| [preserves-definedness] // valid list indexing checked, zero-sized locals materialise trivially | ||
|
|
||
|
Comment on lines
1067
to
1085
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are very useful rules to handle the cases described in #675 .
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solved |
||
| rule <k> rvalueRef(_REGION, KIND, place(local(I), PROJS)) | ||
| => #traverseProjection(toLocal(I), getValue(LOCALS, I), PROJS, .Contexts) | ||
| ~> #forRef(#mutabilityOf(KIND), metadata(#metadataSize(tyOfLocal({LOCALS[I]}:>TypedLocal), PROJS), 0, noMetadataSize)) // TODO: Sus on this rule | ||
|
|
||
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.
Do we actually see this case? (no metadata available)
We have rules for
ZeroSizedconstants with known metadata so if we find this necessary we should investigate it more.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.
interior-mut*functions in feat: model interior borrows for refcell #786There 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.