User account creation filtered due to spam.

Bug 56732 - ICE in advance_target_bb
Summary: ICE in advance_target_bb
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2013-03-25 22:48 UTC by Rajiv Gupta
Modified: 2013-05-31 15:31 UTC (History)
3 users (show)

See Also:
Host:
Target: arm-none-eabi, arm-linux-gnueabi
Build:
Known to work: 4.7.2
Known to fail: 4.8.0
Last reconfirmed: 2013-03-26 00:00:00


Attachments
Preprocessed source code (10.25 KB, application/octet-stream)
2013-03-25 22:48 UTC, Rajiv Gupta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rajiv Gupta 2013-03-25 22:48:34 UTC
Created attachment 29723 [details]
Preprocessed source code

I was trying to compile Ndless with GCC 4.8.0 (configured to cross-compile to arm-none-eabi), and it fails on this file. This compiled in GCC 4.7.2. It seems that it compiles only if I remove the optimization flag or change it to -O1, but not with -O2, -O3, or -Os.

The command line used to compile it is:
"/usr/local/bin/arm-none-eabi-gcc" -mcpu=arm7tdmi -I "/home/rajiv/.ndless/include" -I "/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../include" -I "/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../3rd/nSDL/include" -I "/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../3rd/nspireio/include" -fpic -fno-builtin -D _TINSPIRE -Os -nostdlib -Wall -W -Wno-strict-aliasing -c ploaderhook.c

The error occurs at function plh_hook:

ploaderhook.c: In function ‘plh_hook’:
ploaderhook.c:156:1: internal compiler error: in advance_target_bb, at sched-rgn.c:3552
 HOOK_DEFINE(plh_hook) {
 ^
0x78f082 advance_target_bb
        ../../gcc-4.8.0/gcc/sched-rgn.c:3551
0x78f082 advance_target_bb
        ../../gcc-4.8.0/gcc/sched-rgn.c:3546
0xb35ec2 commit_schedule
        ../../gcc-4.8.0/gcc/haifa-sched.c:5619
0xb40292 schedule_block(basic_block_def**, void*)
        ../../gcc-4.8.0/gcc/haifa-sched.c:6416
0x7946aa schedule_region
        ../../gcc-4.8.0/gcc/sched-rgn.c:3048
0x7946aa schedule_insns
        ../../gcc-4.8.0/gcc/sched-rgn.c:3384
0x7946aa schedule_insns()
        ../../gcc-4.8.0/gcc/sched-rgn.c:3363
0x794a1c rest_of_handle_sched2
        ../../gcc-4.8.0/gcc/sched-rgn.c:3608
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.




Operating System: Ubuntu 12.10 x86_64

Output of arm-none-eabi-gcc -v:

Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/arm-none-eabi/4.8.0/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-4.8.0/configure --target=arm-none-eabi --prefix=/usr/local --enable-interwork --enable-multilib --enable-languages=c,c++ --with-system-zlib --with-newlib --disable-shared --with-gnu-as --with-gnu-ld --with-float=soft --disable-werror
Thread model: single
gcc version 4.8.0 (GCC)

I have attached the preprocessed source code.

-Rajiv
Comment 1 Mikael Pettersson 2013-03-26 09:40:52 UTC
Also reproducible for arm-linux-gnueabi: 4.8.0 ICEs, 4.7.2 and 4.6.3 don't.
Comment 2 Mikael Pettersson 2013-03-26 13:35:30 UTC
Started with http://gcc.gnu.org/r188742 or http://gcc.gnu.org/r188743.

With r188742 I get:

In file included from ploaderhook.c:25:0:
/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../include/os.h: In function 'sprintf':
/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../include/os.h:304:1: error: unrecognizable insn:
(jump_insn 23 22 24 2 (simple_return) /home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../include/os.h:304 -1
     (nil)
 -> simple_return)
/home/rajiv/ndless/ndless/Ndless-SDK/ndless/bin/../include/os.h:304:1: internal compiler error: in extract_insn, at recog.c:2130

Starting with r188743 I get:

ploaderhook.c: In function 'plh_hook':
ploaderhook.c:156:1: internal compiler error: in advance_target_bb, at sched-rgn.c:3466

r188741 was OK.
Comment 3 Richard Biener 2013-03-26 14:23:57 UTC
Thus, confirmed.
Comment 4 gretay 2013-04-26 12:25:49 UTC
I'm looking into it.
Thanks,
Greta
Comment 5 enrico.scholz 2013-04-30 12:07:46 UTC
I can reproduce this error message with gcc-4.8 (patched by OpenEmbedded) on an ARM platform with a simple

----
extern void bar();
void __attribute__((__naked__)) foo(void)
{
        bar();
}
----

$ arm-linux-gnueabi-gcc -O2 -c /tmp/xxx.c 
/tmp/xxx.c: In function 'foo':
/tmp/xxx.c:5:1: internal compiler error: in advance_target_bb, at sched-rgn.c:3552
Comment 6 gretay 2013-05-01 17:32:14 UTC
Thanks for the small testcase! There is indeed a problem with rtl epilogue generated for naked functions. Here is a fix, testing in progress.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 464d91c..9d4a453 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -24067,7 +24067,8 @@ arm_expand_epilogue (bool really_return)
   if (IS_NAKED (func_type)
       || (IS_VOLATILE (func_type) && TARGET_ABORT_NORETURN))
     {
-      emit_jump_insn (simple_return_rtx);
+      if (really_return)
+        emit_jump_insn (simple_return_rtx);
       return;
     }
Comment 7 gretay 2013-05-24 15:18:09 UTC
Author: gretay
Date: Thu May  2 15:45:10 2013
New Revision: 198547

URL: http://gcc.gnu.org/viewcvs?rev=198547&root=gcc&view=rev
Log:
gcc/ChangeLog

2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>

	PR target/56732
	* config/arm/arm.c (arm_expand_epilogue): Check really_return before
	generating simple_return for naked functions.

gcc/testsuite/ChangeLog

2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>

	PR target/56732
	* gcc.target/arm/pr56732-1.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/arm/pr56732-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 gretay 2013-05-24 15:19:23 UTC
Author: gretay
Date: Fri May 24 15:15:44 2013
New Revision: 199296

URL: http://gcc.gnu.org/viewcvs?rev=199296&root=gcc&view=rev
Log:
Backported from mainline
2013-05-02  Greta Yorsh  <Greta.Yorsh@arm.com>

gcc/ChangeLog

    PR target/56732
    * config/arm/arm.c (arm_expand_epilogue): Check really_return before
    generating simple_return for naked functions.
    
gcc/testsuite/ChangeLog
    
    PR target/56732
    * gcc.target/arm/pr56732-1.c: New test.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gcc.target/arm/pr56732-1.c
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/arm/arm.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 9 Rajiv Gupta 2013-05-31 15:31:13 UTC
Great, it's fixed! :)