Hello, <br><br>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:<br>
<br>struct ss<br>{<br>  int a;<br>  int b;<br>  int c;<br>};<br>void loop(struct ss *x, struct ss **y, int z)<br>{<br>  int i;<br>  for (i=0; i<z; ++i)<br>  {<br>    x->c += y[i]->b;<br>  }<br>}<br><br>The problem relies in the register classes for the load and store with displacement instructions:<br>
- load DREGS:$dst, PTR:$p<br>- store DREGS:$src, PTR:$p<br>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.<br>
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. <br>
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 memory.<br>
<br>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.<br><br>Thanks.<br><br>