[cfe-dev] A question on register allocation

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 6 13:36:03 PDT 2015


On Tue, Oct 06, 2015 at 10:07:45AM +0100, Renato Golin via cfe-dev wrote:
> As David said, the only *real* use for global named registers is for
> registers that have a specific meaning throughout the program: the
> stack pointer being the only one that has a useful meaning. You don't
> want to be changing the PC that easily, but if you really do, doing so
> in inline asm is perfectly valid.

This is simplifying things too much. The classic use case for a global
named register is to hold an extremely hot thread local variable. This
is primarily from a time when (a) thread local variable didn't exist and
(b) the overhead typically associated with them on some platforms is too
high. Consider older ARM or MIPS system, where any access to the thread
register would involve a trap. Things like Lisp engines often have a
global context pointer which is easily hot enough to justify burning a
register on it.

Joerg



More information about the cfe-dev mailing list