[cfe-dev] A question on register allocation

Renato Golin via cfe-dev cfe-dev at lists.llvm.org
Sun Oct 4 11:39:03 PDT 2015


On 4 October 2015 at 19:30, Jacques Pienaar via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> You can make the register reserved (requires changing the LLVM backend) and
> then you can use the named global register support added in
> http://reviews.llvm.org/D3261.

Not really. That change was meant *only* for the stack pointers and
will not be accepted upstream for anything else. Don't waste your
time. :)

As an alternative, you can use *local* named registers when using
inline ASM. Something like:

int foo() {
  register int A asm("xmm15");
  asm("mov %0, %0" : "=A" : "A"); // whatever the syntax, I can't remmeber
  return A;
}

The asm block is a trick to tell Clang to honour the register
allocation. AFAICR, without it, Clang will accept it but will not
honour it. You may be lucky.

The reason to all these restrictions is that named registers place the
allocator in FUBAR mode, and we'd rather have it working well before
we start breaking things. It's very likely that this will never be
accepted, though.

cheers,
--renato



More information about the cfe-dev mailing list