Bug 53811 - ICE: in insn_default_length, at config/i386/i386.md:529 (unrecognizable insn) with -mcmodel=large
Summary: ICE: in insn_default_length, at config/i386/i386.md:529 (unrecognizable insn)...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.2
Assignee: Uroš Bizjak
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-06-29 21:29 UTC by Tobias Hansen
Modified: 2012-07-10 17:56 UTC (History)
0 users

See Also:
Host: amd64
Target: x86_64-linux-gnu
Build:
Known to work: 4.6.3
Known to fail: 4.7.0
Last reconfirmed: 2012-07-01 00:00:00


Attachments
preprocessed source (243.57 KB, application/x-gzip)
2012-06-29 21:32 UTC, Tobias Hansen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Hansen 2012-06-29 21:29:08 UTC
I get this ICE with the Debian gcc revision 4.7.0-8.

g++ -I../Engine -I../Common -I../Common/libinclude -mcmodel=large -DTHIS_IS_THE_ENGINE -DLINUX_VERSION -c -o ac.o ac.cpp

ac.cpp:29287:1: error: unrecognizable insn:
(call_insn/j 3 2 4 (call (mem:QI (symbol_ref:DI ("*.LTHUNK0") [flags 0x3] <function_decl 0x7ffff4dd8100 *.LTHUNK0>) [0 S1 A8])
        (const_int 0 [0])) -1
     (nil)
    (nil))
ac.cpp:29287:1: internal compiler error: in insn_default_length, at config/i386/i386.md:529
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
Preprocessed source stored into /tmp/ccpP8zhz.out file, please attach this to your bugreport.
Comment 1 Tobias Hansen 2012-06-29 21:32:47 UTC
Created attachment 27718 [details]
preprocessed source
Comment 2 Uroš Bizjak 2012-07-01 15:40:04 UTC
Can you please test following patch:

--cut here--
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 189101)
+++ config/i386/i386.c  (working copy)
@@ -33056,6 +33056,13 @@ x86_output_mi_thunk (FILE *file,
     emit_jump_insn (gen_indirect_jump (fnaddr));
   else
     {
+      if (!sibcall_insn_operand (fnaddr, Pmode))
+       {
+         tmp = gen_rtx_REG (Pmode, R10_REG);
+         emit_move_insn (tmp, fnaddr);
+         fnaddr = tmp;
+       }
+
       tmp = gen_rtx_MEM (QImode, fnaddr);
       tmp = gen_rtx_CALL (VOIDmode, tmp, const0_rtx);
       tmp = emit_call_insn (tmp);
--cut here--
Comment 3 Uroš Bizjak 2012-07-03 11:07:56 UTC
Patch at [1].

[1] http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00084.html
Comment 4 Tobias Hansen 2012-07-03 11:13:26 UTC
Sorry, I won't get around to compile gcc (never done that yet) and test it.
Comment 5 uros 2012-07-03 11:58:16 UTC
Author: uros
Date: Tue Jul  3 11:58:12 2012
New Revision: 189218

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189218
Log:
	PR target/53811
	* config/i386/i386.c (x86_output_mi_thunk): Check if fnaddr satisfies
	sibcall_insn_operand.  Move it to a temporary register if not.

testsuite/ChangLog:

	PR target/53811
	* g++.dg/other/pr53811.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/other/pr53811.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Dominique d'Humieres 2012-07-04 12:07:15 UTC
g++.dg/other/pr53811.C fails on x86_64-apple-darwin10 with -m64:

FAIL: g++.dg/other/pr53811.C -std=gnu++98 (internal compiler error)
FAIL: g++.dg/other/pr53811.C -std=gnu++98 (test for excess errors)
FAIL: g++.dg/other/pr53811.C -std=gnu++11 (internal compiler error)
FAIL: g++.dg/other/pr53811.C -std=gnu++11 (test for excess errors)

The ICE is

Excess errors:
/opt/gcc/work/gcc/testsuite/g++.dg/other/pr53811.C:29:1: error: insn does not satisfy its constraints:
(insn 3 2 4 (set (reg:DI 59)
        (const:DI (unspec:DI [
                    (symbol_ref:DI ("_ZN12ScriptString12CreateStringEPKc") [flags 0x403] <function_decl 0x142987100 CreateString>)
                ] UNSPEC_GOTOFF))) 62 {*movdi_internal_rex64}
     (nil))

Should I open a new PR?

Note that ' -mcmodel=large' seems to have issues on x86_64-apple-darwin10: see pr50077.
Comment 7 Uroš Bizjak 2012-07-04 12:14:00 UTC
(In reply to comment #6)

> Should I open a new PR?

Yes, please. I will wait with the 4.7 backport until new PR resolves.

> Note that ' -mcmodel=large' seems to have issues on x86_64-apple-darwin10: see
> pr50077.

TBH, -mcmodel=large is currently an overkill, but fixes are fairly trivial (pushing address to temporary reg).
Comment 8 uros 2012-07-06 10:00:20 UTC
Author: uros
Date: Fri Jul  6 10:00:11 2012
New Revision: 189315

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189315
Log:
	PR target/53811
	* config/i386/i386.c (x86_output_mi_thunk): For CM_LARGE_PIC model,
	emit PIC sequence for fnaddr symbol reference in advance.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
Comment 9 uros 2012-07-10 17:53:53 UTC
Author: uros
Date: Tue Jul 10 17:53:48 2012
New Revision: 189412

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189412
Log:
	Backport from mainline
	2012-07-03  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53811
	* config/i386/i386.c (x86_output_mi_thunk): Check if fnaddr satisfies
	sibcall_insn_operand.  Move it to a temporary register if not.

	2012-07-06  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53853
	* config/i386/i386.c (x86_output_mi_thunk): For CM_LARGE_PIC model,
	emit PIC sequence for fnaddr symbol reference in advance.

testsuite/ChangeLog:

	Backport from mainline
	2012-07-03  Uros Bizjak  <ubizjak@gmail.com>

	PR target/53811
	* g++.dg/other/pr53811.C: New test.


Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/other/pr53811.C
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/i386/i386.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 10 Uroš Bizjak 2012-07-10 17:56:05 UTC
Fixed.