New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to find a register to spill in class 'POINTER_REGS' #3972

Open
danlu01 opened this Issue Oct 13, 2015 · 12 comments

Comments

@danlu01

danlu01 commented Oct 13, 2015

I upgraded from Arduino IDE 1.0.6 to 1.6.5 and now my sketch have compile error:

unable to find a register to spill in class 'POINTER_REGS'

I've narrow it down to a function (I've modified it to try to understand the compile error). Odd thing is if I remove any of the 4 line of code in the for loop, then it compiles ok. Here's the test sketch with this issue:

float dhistory[10];
float test;

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

  test = getSlope(dhistory);
}

float getSlope(float history[]) {
  float sumx = 0;
  float sumy = 0;
  float sumxy = 0;
  float sumxsq = 0;
  float rate = 0;
  int n = 10;

  for (int i=1; i< 11; i++) {
    sumx = sumx + i;
    sumy = sumy + history[i-1];
    sumy = sumy + history[i-1];
    sumxsq = sumxsq + (i*i);
  } 

  rate = sumy+sumx+sumxsq;
  return rate;
}
@NicoHood

This comment has been minimized.

Show comment
Hide comment
@NicoHood

NicoHood Oct 13, 2015

Contributor

Please put your code into "```" brackets so it can be read better.
The simple solution to this is: Just DONT us floats on AVR. It just makes no sense at all. also it is important to know what board you used.

Contributor

NicoHood commented Oct 13, 2015

Please put your code into "```" brackets so it can be read better.
The simple solution to this is: Just DONT us floats on AVR. It just makes no sense at all. also it is important to know what board you used.

@danlu01

This comment has been minimized.

Show comment
Hide comment
@danlu01

danlu01 Oct 13, 2015

I'm compiling for Mega2560 but get same error if compile for UNO as well. To me it's a compiler optimization error with pointers.

danlu01 commented Oct 13, 2015

I'm compiling for Mega2560 but get same error if compile for UNO as well. To me it's a compiler optimization error with pointers.

@facchinm

This comment has been minimized.

Show comment
Hide comment
@facchinm

facchinm Oct 13, 2015

Member

Yep, it's a gcc bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040).
If you feel brave you could test if gcc 5.1.0 solves it following these instructions (#660 (comment))

Member

facchinm commented Oct 13, 2015

Yep, it's a gcc bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040).
If you feel brave you could test if gcc 5.1.0 solves it following these instructions (#660 (comment))

@matthijskooijman

This comment has been minimized.

Show comment
Hide comment
@matthijskooijman

matthijskooijman Oct 13, 2015

Collaborator

I just tried 5.1, still broken. I've reduced this testcase to work outside of Arduino and added it to the gcc bug report.

@danlu01, it seems that enabling O2 (more optimizations) prevents this issue from occurring with your code. As a workaround, you could add this near the top of your sketch, to compile just that one function with O2 optimizations:

float getSlope(float history[]) __attribute__((__optimize__("O2")));

(just tried, works for me)

Collaborator

matthijskooijman commented Oct 13, 2015

I just tried 5.1, still broken. I've reduced this testcase to work outside of Arduino and added it to the gcc bug report.

@danlu01, it seems that enabling O2 (more optimizations) prevents this issue from occurring with your code. As a workaround, you could add this near the top of your sketch, to compile just that one function with O2 optimizations:

float getSlope(float history[]) __attribute__((__optimize__("O2")));

(just tried, works for me)

@danlu01

This comment has been minimized.

Show comment
Hide comment
@danlu01

danlu01 Oct 13, 2015

Thanks for the workaround.. run into another compiler bug. I'll create another ticket.

danlu01 commented Oct 13, 2015

Thanks for the workaround.. run into another compiler bug. I'll create another ticket.

@dgholstein

This comment has been minimized.

Show comment
Hide comment
@dgholstein

dgholstein Dec 1, 2015

All;

I have the same problem and it doesn't involve floats (though I use floats elsewhere).

As I uncomment more of my class, the constructor, AD_Synth::AD_Synth(ThreeWire& com_port), I get the "register to spill" message. I tried the attribute workaround with no success.

BTW: When I wrote it all as C-based (not a class) code, the large struct worked just peachy, with essentially the same function as the method.

Sorry about the length of the code and especially the attributes -- but the ADF4351 synthesizer is a complicated device.

Regards,
Dan
synth.ino.txt
AD_synth.cpp.txt
AD_Synth.h.txt
ThreeWire.cpp.txt
ThreeWire.h.txt

dgholstein commented Dec 1, 2015

All;

I have the same problem and it doesn't involve floats (though I use floats elsewhere).

As I uncomment more of my class, the constructor, AD_Synth::AD_Synth(ThreeWire& com_port), I get the "register to spill" message. I tried the attribute workaround with no success.

BTW: When I wrote it all as C-based (not a class) code, the large struct worked just peachy, with essentially the same function as the method.

Sorry about the length of the code and especially the attributes -- but the ADF4351 synthesizer is a complicated device.

Regards,
Dan
synth.ino.txt
AD_synth.cpp.txt
AD_Synth.h.txt
ThreeWire.cpp.txt
ThreeWire.h.txt

@islamelhadi

This comment has been minimized.

Show comment
Hide comment
@islamelhadi

islamelhadi Oct 7, 2016

I was having the same issue and I simply resolved it. All what I did is downloading the LAST UPDATE (4 October 2016 14:52:59 GMT) for Arduino software in the software download page (Arduino software hourly builds) at the bottom left of the page. The sketch was successfully compiled.
HOPE this helps !
https://www.arduino.cc/en/Main/Software
untitled

islamelhadi commented Oct 7, 2016

I was having the same issue and I simply resolved it. All what I did is downloading the LAST UPDATE (4 October 2016 14:52:59 GMT) for Arduino software in the software download page (Arduino software hourly builds) at the bottom left of the page. The sketch was successfully compiled.
HOPE this helps !
https://www.arduino.cc/en/Main/Software
untitled

@njh

This comment has been minimized.

Show comment
Hide comment
@njh

njh Oct 26, 2016

I just tried an hourly build "21 October 2016 16:13:52 GMT" - which came with 'avr-gcc (GCC) 4.9.2' but it didn't solve the problem for me.

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

njh commented Oct 26, 2016

I just tried an hourly build "21 October 2016 16:13:52 GMT" - which came with 'avr-gcc (GCC) 4.9.2' but it didn't solve the problem for me.

error: unable to find a register to spill in class 'POINTER_REGS'
@vitasam

This comment has been minimized.

Show comment
Hide comment
@vitasam

vitasam Oct 29, 2016

Looks like I just got the same problem with Arduino 1.6.11
This line compiles Ok in multiple places of sketch:
sprintf(msg_payload, "%s is ON", module_config.client_name);

but in one place of the sketch this line:
sprintf(msg_payload, "%s connected", module_config.client_name);
returns an error:

...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'
...
        (subreg:QI (reg/f:HI 458) 1)) ...\GITprojects\Sourceforge\home-controller-code\Arduino\AERCM\AERCM.ino:185 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 1 [0x1])

        (nil)))

With just one parameter a compilation is Ok:
sprintf(msg_payload, "%s", module_config.client_name);

vitasam commented Oct 29, 2016

Looks like I just got the same problem with Arduino 1.6.11
This line compiles Ok in multiple places of sketch:
sprintf(msg_payload, "%s is ON", module_config.client_name);

but in one place of the sketch this line:
sprintf(msg_payload, "%s connected", module_config.client_name);
returns an error:

...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.14\cores\arduino\main.cpp:51:1: error: unable to find a register to spill in class 'NO_REGS'
...
        (subreg:QI (reg/f:HI 458) 1)) ...\GITprojects\Sourceforge\home-controller-code\Arduino\AERCM\AERCM.ino:185 1 {pushqi1}

     (expr_list:REG_ARGS_SIZE (const_int 1 [0x1])

        (nil)))

With just one parameter a compilation is Ok:
sprintf(msg_payload, "%s", module_config.client_name);

@matthijskooijman

This comment has been minimized.

Show comment
Hide comment
@matthijskooijman

matthijskooijman Oct 30, 2016

Collaborator

According to the GCC bug, this will be fixed in GCC 7.0. They might backport the fix to earlier versions, if so I think it should be mentioned in the bug report as well. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040

Collaborator

matthijskooijman commented Oct 30, 2016

According to the GCC bug, this will be fixed in GCC 7.0. They might backport the fix to earlier versions, if so I think it should be mentioned in the bug report as well. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040

@ZeusDataBinder

This comment has been minimized.

Show comment
Hide comment
@ZeusDataBinder

ZeusDataBinder Jul 9, 2018

Hello All,
I am still getting the PONITER_REGS error in the UNO board. I am using 1.8.5 IDE!

ZeusDataBinder commented Jul 9, 2018

Hello All,
I am still getting the PONITER_REGS error in the UNO board. I am using 1.8.5 IDE!

@reivaxy

This comment has been minimized.

Show comment
Hide comment
@reivaxy

reivaxy Jul 13, 2018

So am I. Used to work, I don't remember what was the IDE version (had to reinstall everything after hdd crash)

reivaxy commented Jul 13, 2018

So am I. Used to work, I don't remember what was the IDE version (had to reinstall everything after hdd crash)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment