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
{{ message }}
Repository navigation
Impossible constraints when a def and use have same fixed-reg constraint and use is live-out #53
regalloc2 crashes with: 'Could not allocate minimal bundle, but the allocation problem should be possible to solve', regalloc2-0.2.0/src/ion/process.rs:1006:17
It seems to be related to 128-bit multiplication when targeting x86_64. The following is a manually reduced test-case:
changed the title [-]Could not allocate minimal bundle panic[/-][+]Impossible constraints when a def and use have same fixed-reg constraint and use is live-out[/+]on May 30, 2022
Thanks @mchesser ! I just took a look at this and it is indeed a bug. Fortunately (or unfortunately, depending on perspective), I think Cranelift only hits the conditions necessary for it when lowering a 128-bit multiply here, so it is not exposed upward to Wasmtime; so this isn't going to trigger a point-release. That explains why fuzzing hasn't caught it as well.
The basic issue is that an input vreg and an output vreg to one instruction are both constrained to the same preg. So we have:
v0
|
|_ fixed(p0) BEFORE
| mul instruction
| _fixed(p0) AFTER
| |
| v1
: :
: :
The liverange for v0 needs to split just after the fixed(p0) constraint, i.e. just after the Before progpoint. But for a number of other reasons (mainly that we can't insert moves in the middle of instructions!), splits are always "rounded" to the nearest point between instructions. So the LR for v0 is split after the inst, and this conflicts with the fixed(p0) constraint on v1, and we are stuck (so we hit the assert).
I suppose we've never had an instance before of two separate vregs constrained to the same preg at the before- and after-points of a single instruction, so we haven't realized this issue yet.
Probably the best way around this is to use the multi-fixed-reg fixup mechanism to insert a copy if we see that (i) the liverange of a fixed constraint at an use at Before is still live downward, (ii) there is another fixed constraint using the same register at After. I'll play with this a bit.
Activity
[-]Could not allocate minimal bundle panic[/-][+]Impossible constraints when a def and use have same fixed-reg constraint and use is live-out[/+]cfallin commentedon May 30, 2022
Thanks @mchesser ! I just took a look at this and it is indeed a bug. Fortunately (or unfortunately, depending on perspective), I think Cranelift only hits the conditions necessary for it when lowering a 128-bit multiply here, so it is not exposed upward to Wasmtime; so this isn't going to trigger a point-release. That explains why fuzzing hasn't caught it as well.
The basic issue is that an input vreg and an output vreg to one instruction are both constrained to the same preg. So we have:
The liverange for
v0needs to split just after the fixed(p0) constraint, i.e. just after theBeforeprogpoint. But for a number of other reasons (mainly that we can't insert moves in the middle of instructions!), splits are always "rounded" to the nearest point between instructions. So the LR for v0 is split after the inst, and this conflicts with the fixed(p0) constraint on v1, and we are stuck (so we hit the assert).I suppose we've never had an instance before of two separate vregs constrained to the same preg at the before- and after-points of a single instruction, so we haven't realized this issue yet.
Probably the best way around this is to use the multi-fixed-reg fixup mechanism to insert a copy if we see that (i) the liverange of a fixed constraint at an use at Before is still live downward, (ii) there is another fixed constraint using the same register at After. I'll play with this a bit.
Thanks again for the report!
cfallin commentedon May 30, 2022
Also a quick note from investigation just now: the RA2-level fuzz testcase generator ensures that only one constraint exists for a given fixed reg, which is why we didn't find this in RA2 fuzzing.
Extend fuzzer to generate cases like bytecodealliance#53.
Handle conflicting Before and After fixed-reg constraints with a copy.
Handle conflicting Before and After fixed-reg constraints with a copy. (
Some fixes to allow for call instructions to name args, returns, and …
Some fixes to allow for call instructions to name args, returns, and …
Some fixes to allow for call instructions to name args, returns, and …
Some fixes to allow for call instructions to name args, returns, and …