Fixes #147. The Solver::reassign_in() method would previously not record fixed register assignments for values that are already in the correct register. The register would simply be marked as unavailable for the solver. This did have the effect of tripping up the sanity checks in Solver::add_var() when that method was called with such a "reassigned" value. The function can be called for a value that already has a fixed assignment, but the sanity checks want to make sure the variable constraints are compatible with the existing fixed assignment. When no such assignment could be found, the method panicked. To fix this, make sure that even identity reassignments are recorded in the assignments vector. Instead, filter the identity assignments out before scheduling a move sequence for the assignments. Also add some debug tracing to the regalloc solver.
41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
test regalloc
|
|
|
|
isa intel
|
|
|
|
; regex: V=v\d+
|
|
|
|
; The value v9 appears both as the branch control and one of the EBB arguments
|
|
; in the brnz instruction in ebb2. It also happens that v7 and v9 are assigned
|
|
; to the same register, so v9 doesn't need to be moved before the brnz.
|
|
;
|
|
; This ended up confusong the constraint solver which had not made a record of
|
|
; the fixed register assignment for v9 since it was already in the correct
|
|
; register.
|
|
function %pr147(i32) -> i32 native {
|
|
ebb0(v0: i32):
|
|
v1 = iconst.i32 0
|
|
v2 = iconst.i32 1
|
|
v3 = iconst.i32 0
|
|
jump ebb2(v3, v2, v0)
|
|
|
|
ebb2(v4: i32, v5: i32, v7: i32):
|
|
; check: $ebb2
|
|
v6 = iadd v4, v5
|
|
v8 = iconst.i32 -1
|
|
; v7 is killed here and v9 gets the same register.
|
|
v9 = iadd v7, v8
|
|
; check: $v9 = iadd $v7, $v8
|
|
; Here v9 the brnz control appears to interfere with v9 the EBB argument,
|
|
; so divert_fixed_input_conflicts() calls add_var(v9), which is ok. The
|
|
; add_var sanity checks got confused when no fixed assignment could be
|
|
; found for v9.
|
|
;
|
|
; We should be able to handle this situation without making copies of v9.
|
|
brnz v9, ebb2(v5, v6, v9)
|
|
; check: brnz $v9, $ebb2($V, $V, $v9)
|
|
jump ebb3
|
|
|
|
ebb3:
|
|
return v5
|
|
}
|