Bug 58545 - [4.8 Regression] error: unable to find a register to spill in class 'POINTER_REGS'
Summary: [4.8 Regression] error: unable to find a register to spill in class 'POINTER_...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.1
: P4 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, ra
Depends on:
Blocks: 56183
  Show dependency treegraph
 
Reported: 2013-09-26 15:48 UTC by Georg-Johann Lay
Modified: 2015-06-23 08:40 UTC (History)
2 users (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.6.2, 4.9.0
Known to fail: 4.7.2, 4.8.1, 4.8.5
Last reconfirmed: 2013-09-26 00:00:00


Attachments
bug.c C source code (184 bytes, text/plain)
2013-09-26 15:49 UTC, Georg-Johann Lay
Details
patch currently under test (1.38 KB, patch)
2013-10-03 15:38 UTC, Jorn Wolfgang Rennecke
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2013-09-26 15:48:10 UTC
== C source ==

typedef unsigned char uint8_t;
typedef unsigned int uint16_t;

extern uint8_t f1 (const uint8_t*);
extern void f2 (uint8_t*, uint8_t);

void func (uint16_t parameter, uint8_t *addr, uint8_t data)
{
   uint8_t status;

   status = f1 (addr + 8);

   addr++;

   if (*addr == parameter + 8)
      *addr = parameter;

   f2 (addr, data);
   f2 (addr + 8, status + 1);
}

== Command line ==

$ avr-gcc bug.c -S -Os -mmcu=atmega8
bug.c: In function 'func':
bug.c:20:1: error: unable to find a register to spill in class 'POINTER_REGS'
 }
 ^
bug.c:20:1: error: this is the insn:
(insn 37 15 16 2 (set (reg:QI 20 r20)
        (mem/c:QI (plus:HI (reg/f:HI 28 r28)
                (const_int 1 [0x1])) [3 S1 A8])) bug.c:15 70 {movqi_insn}
     (nil))
bug.c:20:1: internal compiler error: in spill_failure, at reload1.c:2123

bug.c:20:1: internal compiler error: Segmentation fault

== configure == 

Configured with: ../../gcc.gnu.org/trunk/configure --target=avr --prefix=/local/gnu/install/gcc-4.8-mingw32 --host=i386-mingw32 --build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared --with-dwarf2

== Notes ==

The compile passes with -fno-caller-saves
Comment 1 Georg-Johann Lay 2013-09-26 15:49:46 UTC
Created attachment 30906 [details]
bug.c C source code
Comment 2 Richard Biener 2013-09-27 08:10:11 UTC
Assuming 4.9 doesn't work either.
Comment 3 Jorn Wolfgang Rennecke 2013-10-03 15:32:05 UTC
Instruction 37 is generated by save_call_clobbered_regs.
When the eliminable registers were initialized, the frame size was
zero, and the frame pointer could be eliminated.
The frame size grew when the save area for r20 was allocated, but
reload does not update the eliminable registers in this case.
Therefore, the frame pointer r28 was eliminated to the stack pointer
in insn 37.  Thus, finding reloads and spilling finished with
insn 37 using the stack pointer and needing a POINTER_REGS reload.
Then, before it comes to selecting the reload registers, the eliminables
are updated, but not the reloads that depend on them.  Thus, we
try - unnecessarily - to reload the frame pointer, and can't because
r28 is in use as the frame pointer.
Comment 4 Jorn Wolfgang Rennecke 2013-10-03 15:38:58 UTC
Created attachment 30951 [details]
patch currently under test
Comment 5 Jorn Wolfgang Rennecke 2013-10-30 23:55:48 UTC
Author: amylaar
Date: Wed Oct 30 23:55:46 2013
New Revision: 204234

URL: http://gcc.gnu.org/viewcvs?rev=204234&root=gcc&view=rev
Log:
gcc:
        PR other/58545
        * reload1.c (update_eliminables_and_spill): New function, broken
        out of reload.
        (reload): Use it.  Check for frame size change after frame
        size alignment, and call update_eliminables_and_spill first
        if continue-ing.
gcc/testsuite:
        PR other/58545
        * gcc.target/avr/pr58545.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/avr/pr58545.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload1.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Richard Biener 2013-11-05 14:31:37 UTC
I assume fixed on trunk.
Comment 7 Georg-Johann Lay 2014-02-17 16:41:14 UTC
*** Bug 60040 has been marked as a duplicate of this bug. ***
Comment 8 Richard Biener 2014-06-12 13:41:46 UTC
The 4.7 branch is being closed, moving target milestone to 4.8.4.
Comment 9 Jakub Jelinek 2014-12-19 13:24:47 UTC
GCC 4.8.4 has been released.
Comment 10 Richard Biener 2015-06-23 08:40:56 UTC
Fixed for 4.9.0.