Emit new indirect guards when parents have different starts - #50
Merged
Conversation
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
force-pushed
the
afabre/indirect
branch
from
August 27, 2026 11:14
b3940fd to
41b40f0
Compare
arthurfabre
marked this pull request as ready for review
August 27, 2026 11:19
Dhiver
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.