[LLVMdev] LLVM ERROR: ran out of registers during register allocation

Borja Ferrer borja.ferav at gmail.com
Mon Dec 17 08:38:27 PST 2012


I'm getting the "LLVM ERROR: ran out of registers during register
allocation" error message for an out of tree target I'm developing. This is
happening for the following piece of C code:

struct ss
  int a;
  int b;
  int c;
void loop(struct ss *x, struct ss **y, int z)
  int i;
  for (i=0; i<z; ++i)
    x->c += y[i]->b;

The problem relies in the register classes for the load and store with
displacement instructions:
- load DREGS:$dst, PTR:$p
- store DREGS:$src, PTR:$p
where DREGS is a regclass composed of 16 registers and PTR is a regclass
composed of 2 registers, but the key point here is that PTR is a subset of
DREGS, so cross class copies are perfectly allowed.
One of the 2 registers in the PTR regclass is reserved for the frame
pointer, leaving only one register to access both x and y[i] in the code
above, which seems to confuse the regalloc. Implementing
getLargestLegalSuperClass() sort of helped for simpler functions, but not
for this one.
This code can be register-allocted if the addresses of both x and y[i] are
cross class copied to DREGS registers to temporarily store these values and
then when required copied back to the the register in PTR to access them in

Any help for a solution or a workaround will be greatly appreciated since
this problem is severily limiting the complexity of the programs that I can
currently compile.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/95a82097/attachment.html>

More information about the llvm-dev mailing list