Skip to content

Emit new indirect guards when parents have different starts - #50

Merged
arthurfabre merged 1 commit into
masterfrom
afabre/indirect
Aug 28, 2026
Merged

Emit new indirect guards when parents have different starts#50
arthurfabre merged 1 commit into
masterfrom
afabre/indirect

Conversation

@arthurfabre

Copy link
Copy Markdown
Collaborator

If a block has two parents, that each make a LoadIndirect with a different start, we wouldn't always emit a new guard if the block did a LoadIndirect itself: if the start was greater, we'd consider it covered under the parents' guards.

But as of commit ce7ee68 "Validate variable packet offsets, support negative offsets", we store the packet pointer plus the start offset in a register.

If the guards have different starts, this register will therefore have a different value. We can't naively use it in the child block.

Emit new guards (to load a new value in the register) when the start is different.

@arthurfabre arthurfabre self-assigned this Aug 27, 2026
@arthurfabre
arthurfabre marked this pull request as draft August 27, 2026 08:36
If a block has two parents, that each make a LoadIndirect with a
different start, we wouldn't always emit a new guard if the block did a
LoadIndirect itself: if the start was greater, we'd consider it covered
under the parents' guards.

But as of commit ce7ee68 "Validate variable packet offsets, support
negative offsets", we store the packet pointer plus the start offset in
a register.

If the guards have different starts, this register will therefore have a
different value. We can't naively use it in the child block.

Emit new guards (to load a new value in the register) when the start is
different.

For the C backend: move the asm volatile constraint just after
calculating indirect, so clang can't assume it's value and reuse it
between guards.
Switch indirect from being a input, to an input / output so clang can't
know it's value.
@arthurfabre
arthurfabre marked this pull request as ready for review August 27, 2026 11:19
@arthurfabre
arthurfabre merged commit bb2a07b into master Aug 28, 2026
10 checks passed
@arthurfabre
arthurfabre deleted the afabre/indirect branch August 28, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants