Bug 71873 - ICE in push_reload
Summary: ICE in push_reload
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: 7.0
Assignee: Senthil Kumar Selvaraj
URL:
Keywords:
: 67031 71932 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-07-14 07:09 UTC by Senthil Kumar Selvaraj
Modified: 2016-10-20 12:12 UTC (History)
2 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Senthil Kumar Selvaraj 2016-07-14 07:09:44 UTC
The following testcase causes an ICE in push_reload when compiled with 

$ cat test.c
#include <stdint.h>

typedef struct {
  uint8_t x;
  uint32_t y;
} A;

A a;

extern int bar(int);
extern int foo (char *s, ...);

extern uint8_t param;
extern uint8_t h,m,s,ld,lm;
extern uint16_t d;

void gps_parse_string(int z)
{
  while (bar(z))
  {
    switch (param)
    {
      case 0: foo("a", &h, &m, &s, &d); break;
      case 1: foo("d", &ld, &lm, &a.y); break;
    }
  }
}


$ avr-gcc -Os -mmcu=atmega8 -S test.c
test.c: In function 'gps_parse_string':
test.c:27:1: internal compiler error: in push_reload, at reload.c:1349
 }
 ^
0xd8feb0 push_reload(rtx_def*, rtx_def*, rtx_def**, rtx_def**, reg_class, machine_mode, machine_mode, int, int, int, reload_type)
	/home/saaadhu/code/work/gcc/gcc/reload.c:1348
0xd8f760 push_reload(rtx_def*, rtx_def*, rtx_def**, rtx_def**, reg_class, machine_mode, machine_mode, int, int, int, reload_type)
	/home/saaadhu/code/work/gcc/gcc/reload.c:1155
0xd97e86 find_reloads(rtx_insn*, int, int, int, short*)
	/home/saaadhu/code/work/gcc/gcc/reload.c:4035
0xda58d4 calculate_needs_all_insns
	/home/saaadhu/code/work/gcc/gcc/reload1.c:1483
0xda4018 reload(rtx_insn*, int)
	/home/saaadhu/code/work/gcc/gcc/reload1.c:995
0xc0865e do_reload
	/home/saaadhu/code/work/gcc/gcc/ira.c:5396
0xc08a46 execute
	/home/saaadhu/code/work/gcc/gcc/ira.c:5568
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Might be a duplicate of PR 67031, but the testcases there do not cause an ICE on trunk (gcc version 7.0.0 20160704), but the above one does.
Comment 1 Senthil Kumar Selvaraj 2016-08-10 12:36:29 UTC
Author: saaadhu
Date: Wed Aug 10 12:35:57 2016
New Revision: 239321

URL: https://gcc.gnu.org/viewcvs?rev=239321&root=gcc&view=rev
Log:
Fix PR 71873 - ICE in push_reload

Extend computation of subreg_in_class to constants and plus expressions 
inside SUBREGs, before recursively calling push_reload. SYMBOL_REFs are
also CONSTANT_P, so remove explicit handling of SYMBOL_REFs.

gcc/ChangeLog

	PR target/71873
	* reload.c (push_reload): Compute subreg_in_class for
	subregs of constants and plus expressions. Remove special
	handling of SYMBOL_REFs.

gcc/testsuite/ChangeLog

	PR target/71873
	* gcc.target/avr/pr71873.c: New test.

Added:
    trunk/gcc/testsuite/gcc.target/avr/pr71873.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/reload.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Senthil Kumar Selvaraj 2016-08-22 09:43:08 UTC
Maintainers did not approve backporting, so fixed on trunk (7.0) only.
Comment 3 Senthil Kumar Selvaraj 2016-08-22 10:18:48 UTC
*** Bug 67031 has been marked as a duplicate of this bug. ***
Comment 4 Senthil Kumar Selvaraj 2016-10-20 12:12:09 UTC
*** Bug 71932 has been marked as a duplicate of this bug. ***