[LLVMdev] Named register variables GNU-style

Renato Golin renato.golin at linaro.org
Thu Mar 27 15:32:21 PDT 2014


On 27 March 2014 21:52, Richard Smith <richard at metafoo.co.uk> wrote:
> I don't think that works. Per the GCC documentation, a global register
> variable reserves the register entirely for use with that name in a
> translation unit. We don't seem to want exactly that model, but the approach
> you're suggesting doesn't seem to capture the semantics.

The IR in question has no mention that the register cannot be
reserved. In fact we do that already in the ARM back-end, reserving
the R9 for special purposes. We could very well reserve the register
in question to not be used. Some of us also mentioned that we should
reserve the register, and I think there's nothing stopping us from
reserving the registers on a compilation unit (module) level for
global named registers.

The problem here is that you can't reserve all registers. On ARM,
R0~R3, SP, LR and PC (and sometimes R9 or R11) cannot be fully
reserved, as they are part of the PCS/execution model, or are reserved
already. GCC docs state that "it's not safe" assuming those things
will by reserved, which is the same effect. The stack pointer can
still be safely used for reading, for example, as is the case of
unwinding.

cheers,
--renato



More information about the llvm-dev mailing list