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)) Note that ' -mcmodel=large' seems to have issues on x86_64-apple-darwin10: see pr50077.
Also on i686-darwin9 @m64 As commented in 50077, we don't support the large model. I suppose the best thing to do in the short(ish) term is to make a target test for large model support and make the tests that require it do that test. Addition of large model support would be nice - but might be optimistic for 4.8 with the resources available to darwin at present.
It turned out that -mcmodel -fPIC also ICEd on x86_64-pc-linux-gnu. We need additional part to handle CM_LARGE_PIC, basically: --cut here-- @@ -33057,6 +33059,10 @@ x86_output_mi_thunk (FILE *file, emit_jump_insn (gen_indirect_jump (fnaddr)); else { + if (ix86_cmodel == CM_LARGE_PIC + && GET_CODE (fnaddr) == SYMBOL_REF) + fnaddr = construct_plt_address (fnaddr, + gen_rtx_REG (Pmode, tmp_regno)); if (!sibcall_insn_operand (fnaddr, word_mode)) { tmp = gen_rtx_REG (word_mode, tmp_regno); --cut here-- to create: .size _ZN12ScriptString12CreateStringEPKc, .-_ZN12ScriptString12CreateStringEPKc .set .LTHUNK0,_ZN12ScriptString12CreateStringEPKc .p2align 4,,15 .globl _ZThn8_N12ScriptString12CreateStringEPKc .type _ZThn8_N12ScriptString12CreateStringEPKc, @function _ZThn8_N12ScriptString12CreateStringEPKc: .LFB1: .cfi_startproc subq $8, %rdi movabsq $.LTHUNK0@PLTOFF, %r10 addq %rbx, %r10 jmp *%r10 .cfi_endproc I'd like to ask Jakub fo opinion here. The generated code otherwise works OK for a couple of tests (g++.dg/inherit/thunk*.C) when compiled with -mcmodel=large -fPIC.
Created attachment 27746 [details] Patch to fix the ICE with -fPIC The complete patch in testing.
The patch in comment #3 fixes the PR. Full regstrapping scheduled for tonight.
We can leave all the magic to legitimize_pic_address, so following alternative patch is much clearer: --cut here-- Index: i386.c =================================================================== --- i386.c (revision 189310) +++ i386.c (working copy) @@ -33057,6 +33057,10 @@ x86_output_mi_thunk (FILE *file, emit_jump_insn (gen_indirect_jump (fnaddr)); else { + if (flag_pic && SYMBOLIC_CONST (fnaddr)) + fnaddr = legitimize_pic_address (fnaddr, + gen_rtx_REG (Pmode, tmp_regno)); + if (!sibcall_insn_operand (fnaddr, word_mode)) { tmp = gen_rtx_REG (word_mode, tmp_regno); --cut here-- With this patch, we get: .size _ZN1D4foo2Ev, .-_ZN1D4foo2Ev .set .LTHUNK0,_ZN1D4foo2Ev .p2align 4,,15 .globl _ZThn16_N1D4foo2Ev .type _ZThn16_N1D4foo2Ev, @function _ZThn16_N1D4foo2Ev: .LFB15: .cfi_startproc subq $16, %rdi movabsq $.LTHUNK0@GOTOFF, %r10 addq %rbx, %r10 jmp *%r10 .cfi_endproc .LFE15: .size _ZThn16_N1D4foo2Ev, .-_ZThn16_N1D4foo2Ev So, load off GOTOFF table, which works as well.
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/53853 * 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
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
Fixed.