You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When testing changes to the allocator related to #129 I was running the allocator on chains randomly generated by alg/rand.SolverGenerator. This test triggered an assertion in the allocator:
Allocation is done like liveness analysis: the instructions are processed in reverse and variables are allocated as they are read, freed when they're written to. Therefore this assertion would trigger if the operand is never read after it's written.
It appears this is actually what's happening. See the example:
It seems there's either a bug somewhere, perhaps in the conversion from addchain.Program to ir.Program, or this is a trivial optimization pass that could be added to alg/opt.
The text was updated successfully, but these errors were encountered:
No, although I did hit that independently when messing around. Definitely could use a little deadcode pass. I don’t think it shows up much in practice, because the other generators don’t generate dead chain entries.
The variable allocator currently raises an assertion error if it encounters a
write to an operand without an allocation. Allocation is done like liveness
analysis: the instructions are processed in reverse and variables are
allocated as they are read, freed when they're written to. Therefore this
assertion would trigger if the operand is never read after it's written.
Therefore, this would only happen for a _redundant_ chain which computes a
value it never needs. Clearly this isn't ideal, but it does seem to happen for
some algorithms. It seems best that the allocator doesn't crash in these
cases.
This PR updates the allocation logic to handle this case. In practice if this
happens the variable would be immediately allocated and freed.
Updates #129#133#136
When testing changes to the allocator related to #129 I was running the allocator on chains randomly generated by
alg/rand.SolverGenerator
. This test triggered an assertion in the allocator:addchain/acc/pass/alloc.go
Lines 51 to 55 in 2cfd897
Allocation is done like liveness analysis: the instructions are processed in reverse and variables are allocated as they are read, freed when they're written to. Therefore this assertion would trigger if the operand is never read after it's written.
It appears this is actually what's happening. See the example:
Example
It seems there's either a bug somewhere, perhaps in the conversion from
addchain.Program
toir.Program
, or this is a trivial optimization pass that could be added toalg/opt
.The text was updated successfully, but these errors were encountered: