compiler.cfg.linear-scan.allocation.state: fix #1345 by adding vreg to

the heap key

By having { start end vreg } as the key in the min-heap ordering is
guaranteed even if two intervals share the same start and end.
db4
Björn Lindqvist 2015-06-14 06:13:34 +02:00
parent 9dbb3e9171
commit 91118ae5df
2 changed files with 17 additions and 18 deletions

View File

@ -137,27 +137,27 @@ cpu x86.64? [
cfg get
] unit-test
{ { 33 1/0.0 } } [
T{ sync-point { n 33 } } sync-point-key
{ { 33 1/0.0 1/0.0 } } [
T{ sync-point { n 33 } } interval/sync-point-key
] unit-test
{
{
{ { 5 1/0. } T{ sync-point { n 5 } } }
{ { 5 1/0. 1/0. } T{ sync-point { n 5 } } }
{
{ 20 28 }
{ 20 28 f }
T{ live-interval-state { start 20 } { end 28 } }
}
{
{ 20 30 }
{ 20 30 f }
T{ live-interval-state { start 20 } { end 30 } }
}
{
{ 33 999 }
{ 33 999 f }
T{ live-interval-state { start 33 } { end 999 } }
}
{ { 33 1/0. } T{ sync-point { n 33 } } }
{ { 100 1/0. } T{ sync-point { n 100 } } }
{ { 33 1/0. 1/0. } T{ sync-point { n 33 } } }
{ { 100 1/0. 1/0. } T{ sync-point { n 100 } } }
}
} [
{

View File

@ -18,18 +18,19 @@ SYMBOL: progress
SYMBOL: unhandled-min-heap
: live-interval-key ( live-interval -- key )
[ start>> ] [ end>> ] bi 2array ;
GENERIC: interval/sync-point-key ( interval/sync-point -- key )
: sync-point-key ( sync-point -- key )
n>> 1/0. 2array ;
M: live-interval-state interval/sync-point-key
[ start>> ] [ end>> ] [ vreg>> ] tri 3array ;
M: sync-point interval/sync-point-key
n>> 1/0. 1/0. 3array ;
: zip-keyed ( seq quot: ( elt -- key ) -- alist )
[ keep ] curry { } map>assoc ; inline
: >unhandled-min-heap ( live-intervals sync-points -- min-heap )
[ [ live-interval-key ] zip-keyed ]
[ [ sync-point-key ] zip-keyed ] bi* append >min-heap ;
append [ interval/sync-point-key ] zip-keyed >min-heap ;
SYMBOL: registers
@ -108,10 +109,8 @@ ERROR: register-already-used live-interval ;
} process-intervals ;
: add-unhandled ( live-interval -- )
[ check-unhandled ]
[
dup live-interval-key unhandled-min-heap get heap-push
] bi ;
dup check-unhandled
dup interval/sync-point-key unhandled-min-heap get heap-push ;
: reg-class-assoc ( quot -- assoc )
[ reg-classes ] dip { } map>assoc ; inline