error: unable to find a register to spill in class 'POINTER_

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all,

I get a weird compiler error:

clktsk.c: In function 'main':
clktsk.c:2934:1: error: unable to find a register to spill in class 'POINTER_REGS'
clktsk.c:2934:1: error: this is the insn:
(insn 3102 796 3103 64 (set (reg:QI 26 r26)
        (reg:QI 890)) clktsk.c:2066 28 {movqi_insn}
     (nil))
clktsk.c:2934: confused by earlier errors, bailing out

avr-gcc is version 4.7.2; command line was as follows:

/usr/bin/avr-gcc -g -c -DGCCAVR -DHDWFIL=\"clkhdw.h\" -I/usr/avr/include/avr -funsigned-bitfields -DDEBUG  -O1 -mrelax -fno-caller-saves -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -gstrict-dwarf -Wall  -DMEG -mmcu=atmega1284p -DLTTEND -DSTRLEN=64 -DNSTMAX=6 -DTSTRS2 -DTSTCTL=1 -DTSTBDR=38400 -DERHCTL=TSTCTL -DERHBDR=TSTBDR -DTST -c -std=gnu99 -o clktsk.o clktsk.c

I saw that other people in the forum got this error before but I could not find a workaround. -fno-caller-saves seems to have worked for some (didn't work for me though) and I cannot change optimisation level (-O1).

Any other suggestions what I can try?
Or can somebody explain what may be confusing the compiler?

Kind Regards,
Hagen

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe split the 2934(+) line file?

In fact start with the one member function where that error is reported and see if it is that alone that leads to the error. If it is try to split the complexity of the function.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is one (I have to admit big) function with one switch() and a few case statements; imho not complex.

I don't believe in distributing functions that logically belong together over several source files; I actually can't see why that would solve the problem here.

So it seems the function size is the root cause of the problem. For various reasons I'd like to avoid splitting it up.

I'm not aware that the C language limits the complexity of a function or the size of a source file.

So why has the avr-gcc compiler a problem here where other compilers don't?

-O2 removes the compiler error, so I can probably live with it for the moment.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I'm not aware that the C language limits the complexity of a function or the size of a source file.

The IMPLEMENTATION does.
Quote:

So why has the avr-gcc compiler a problem here where other compilers don't?

The source of avr-gcc is completely open - it's just as easy for you as anyone else to explore and "fix" this but it may not be easy as the way GCC works is to convert the C to a generic internal representation (GENERIC->GIMPLE) and then this is processed by the AVR code generator so it may not be something easily "fixed" on the AVR side of the fence and woe-betide anyone who wants to mess wit the generic stuff that might break the ARM or x86 implementations.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The compiler is saying it ran out of registers. Specifically, it is saying it ran out of "pointer" registers (X,Y and Z for AVR). What version of the compiler is this, and can you share the code that makes the compiler generate this?

Regards

Senthil

 

blog | website

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
The IMPLEMENTATION does.

Ok, I wasn't aware of that either.
clawson wrote:
The source of avr-gcc is completely open - it's just as easy for you as anyone else to explore and "fix" this

You are right; it is as easy (speak "difficult") for me to fix this. I'd like to contribute to open source software but to be very honest the whole gnu compiler and associated code generating system has reached a complexity that I would not dare to tackle this during the life time I have left.

It wasn't my intention to criticise the gnu avr compiler, it is a great piece of work and despite the overlaying generic gnu compiler it creates good assembler code. I evaluated two commercial compilers in the past; one was a disappointment on all levels and another really expensive one has not solved the Harvard architecture problem either, so no advantage here.

All I wanted to know if there is somebody here that can shed light on the problem (which you partly did already by mentioning complexity) and how to work around it. Actually without the kind support of Jörg Wunsch a couple of months ago I would not be able to use the compiler at all.

@saaadhu: I quoted compiler version above. I'm afraid I cannot share the code here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

saaadhu wrote:
The compiler is saying it ran out of registers.
That might be the case for some weird and rare inline assembler, but for C plain code this is not the case. For plain C code, it's likely one of the known many register allocator problems, cf. PR56183.

There are still so many of these bugs because they are so hard to fix and because reduced interest in avr-gcc.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only assembler statement in this file is "sleep" which should not have any effect.

clawson is right when he claims that my code is too complex; I would not use it as an example to teach programming :-) but I had reason to write it like that. Although the example in Bug 58545 is surprisingly short.

Since I refactored the whole file and using -O2 the problem disappeared anyway.

Quote:
...and because reduced interest in avr-gcc.

Maintainers or users?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Contributors.

avrfreaks does not support Opera. Profile inactive.