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 cfg get
] unit-test ] unit-test
{ { 33 1/0.0 } } [ { { 33 1/0.0 1/0.0 } } [
T{ sync-point { n 33 } } sync-point-key T{ sync-point { n 33 } } interval/sync-point-key
] unit-test ] 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 } } T{ live-interval-state { start 20 } { end 28 } }
} }
{ {
{ 20 30 } { 20 30 f }
T{ live-interval-state { start 20 } { end 30 } } T{ live-interval-state { start 20 } { end 30 } }
} }
{ {
{ 33 999 } { 33 999 f }
T{ live-interval-state { start 33 } { end 999 } } T{ live-interval-state { start 33 } { end 999 } }
} }
{ { 33 1/0. } T{ sync-point { n 33 } } } { { 33 1/0. 1/0. } T{ sync-point { n 33 } } }
{ { 100 1/0. } T{ sync-point { n 100 } } } { { 100 1/0. 1/0. } T{ sync-point { n 100 } } }
} }
} [ } [
{ {

View File

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