Skip to content

Conversation

@Stevengre
Copy link
Contributor

No description provided.

@Stevengre Stevengre marked this pull request as ready for review November 7, 2025 05:24
@Stevengre Stevengre self-assigned this Nov 7, 2025
@jberthold
Copy link
Member

Related: #675

Comment on lines 132 to 137
// 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)
Copy link
Member

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 ZeroSized constants with known metadata so if we find this necessary we should investigate it more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 1098 to 1109
// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are very useful rules to handle the cases described in #675 .
Maybe we could call #decodeConstant instead of assuming an Aggregate and inserting it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved

@Stevengre Stevengre changed the title feat(rt): handle zero-sized constant and locals feat(rt): handle zero-sized locals Nov 10, 2025
Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Actually, could you add tests from issue #675 ?

Comment on lines +294 to +299
if not component_tys:
if data:
raise ValueError(f'Zero-sized tuple expected empty data, got: {data!r}')
return AggregateValue(0, [])

raise ValueError('Tuple decoding with components is not implemented yet')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please create an issue to add tuple decoding?
It depends on how the layout is, maybe we can just decode the components in sequence? Or can the fields be out of order for tuples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit 5b8ce03 into master Nov 10, 2025
7 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the jh/zero-sized branch November 10, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants