Bug 61561 - arm gcc internal error
Summary: arm gcc internal error
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.0
: P3 major
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2014-06-19 13:00 UTC by Marat Zakirov
Modified: 2014-07-11 14:44 UTC (History)
0 users

See Also:
Host:
Target: arm-*-*
Build:
Known to work:
Known to fail: 4.10.0, 4.7.4, 4.8.3, 4.9.1
Last reconfirmed: 2014-06-19 00:00:00


Attachments
Proposed patch (828 bytes, patch)
2014-06-19 13:00 UTC, Marat Zakirov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marat Zakirov 2014-06-19 13:00:13 UTC
Created attachment 32973 [details]
Proposed patch

To reproduce the issue do:
1) Configure gcc for arm as traget and x86 as host.
$ ./configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=arm-v7a15v5r2-linux-gnueabi --prefix=/home/mzakirov/proj/gcc_arm_ref/arm-v7a15v5r2 --with-sysroot=/your_arm/sys-root
2) make -j6
3) make install
4) Compile following:
$ cat ex.c
int dummy(int a);

char a;

void mmm (void)
{
  char dyn[ dummy(3) ];
  a = (char)&dyn[0];
}
$ gcc -O3 ex.c -o ex.o 
ex.c: In function ‘mmm’:
ex.c:8:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   a = (char)&dyn[0];
       ^
ex.c:9:1: internal compiler error: in check_rtl, at lra.c:1919
 }
 ^
0x8689e5 check_rtl
	/home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/lra.c:1919
0x86bde5 lra(_IO_FILE*)
	/home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/lra.c:2309
0x82b02e do_reload
	/home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/ira.c:5325
0x82b02e execute
	/home/mzakirov/proj/gcc_arm_ref/build.arm.cortex-a15/sources/gcc_1/gcc/ira.c:5486
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

Analysis showed that the problem in instruction like:
(insn 26 12 18 2 (set (reg:QI 2 r2)
        (reg:QI 13 sp)) ex.c:8 205 {*arm_movqi_insn}
     (nil))
gcc cse propogates sp register to (char/short) cast from a pointer (32 bit value) and reload phase fails because gcc do not founds applicable template for loading a byte or word from sp.
Adding correct template to arm.md fixes the issue. See attached patch.

Note: that issue appeared while translating linux kernel for arm.
Comment 1 ktkachov 2014-06-19 13:06:13 UTC
Confirmed for trunk, 4.9 and 4.8.

Marat, please send the patch to gcc-patches@gcc.gnu.org with an appropriate ChangeLog entry and the included testcase for review.
Comment 2 ktkachov 2014-06-19 13:17:30 UTC
Also ICEs on 4.7.4, I guess that's been this way for a while
Comment 3 ktkachov 2014-06-19 13:20:32 UTC
FWIW On 4.7.4 without LRA the ICE is:
ice.c:9:1: error: insn does not satisfy its constraints:
(insn 25 12 19 2 (set (reg:QI 2 r2)
        (reg:QI 13 sp)) ice.c:8 193 {*arm_movqi_insn}
     (nil))

But 4.7 is no loner maintained, so that's more of a trivia at this point
Comment 4 mzakirov 2014-07-11 09:03:11 UTC
Author: mzakirov
Date: Fri Jul 11 09:02:39 2014
New Revision: 212450

URL: https://gcc.gnu.org/viewcvs?rev=212450&root=gcc&view=rev
Log:
gcc/
2014-07-11  Marat Zakirov  <m.zakirov@samsung.com>

	PR target/61561
	* config/arm/arm.md (*movhi_insn_arch4): Handle stack pointer.
	(*movhi_bytes): Likewise.
	(*arm_movqi_insn): Likewise. 

gcc/testsuite/
2014-07-11  Marat Zakirov  <m.zakirov@samsung.com>

	PR target/61561
	* gcc.dg/pr61561.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/pr61561.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.md
    trunk/gcc/testsuite/ChangeLog
Comment 5 Marat Zakirov 2014-07-11 10:53:14 UTC
fixed