[fpc-devel] Register allocation question

Sergei Gorelkin sergei_gorelkin at mail.ru
Sun Apr 10 12:38:08 CEST 2011


10.04.2011 00:49, Florian Klämpfl пишет:
> Am 09.04.2011 22:22, schrieb Sergei Gorelkin:
>> 09.04.2011 23:10, Florian Klämpfl пишет:
>>>
>>> Problem is, this might hurt non leaf functions. Maybe the register
>>> allocators can be initialized differently for leave and non-leave
>>> functions?
>>
>> I understand the concern, but it should be handled somehow already. If
>> we consider a non-leaf function that is complex enough to consume all 14
>> registers, what difference does the order of allocation make?
>
> It is not needed to use all 14, but it might be more benefical to use
> those which are preserved across a function call.
>
>> When
>> making a call, it must know which registers will be destroyed and which
>> won't, otherwise result will be wrong anyway.
>> What I see confirms what I think: non-leaf functions continue to use
>> rbx, rsi and rdi, not r8..r11.
>
> So the code for those does not change?

Some do not change (that's why I was initially writing that it doesn't work), other change, but 
never to the worse. For example, if register was e.g. rbx but its live range was not intersecting 
the call, then it is replaced by volatile one like r8. If its live range intersects the call, it can 
be changed to other nonvolatile register like rdi. Likewise, registers within volatile group are 
interchanged. But I don't see it replacing nonvolatile register with volatile one if that would 
require adding spilling instructions.

By now I had run the test suite in x86_64-linux, without regressions.


Sergei




More information about the fpc-devel mailing list