Created attachment 30715 [details] Preprocessed file On x86_64-apple-darwin10 building libobjc gives the following ICE after revision 201915 ... libtool: compile: /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/sys-include /opt/gcc/work/libobjc/sendmsg.c -c -I. -I/opt/gcc/work/libobjc -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing -fexceptions -I/opt/gcc/work/libobjc/../gcc -I/opt/gcc/work/libobjc/../gcc/config -I../.././gcc -I/opt/gcc/work/libobjc/../libgcc -I../libgcc -I/opt/gcc/work/libobjc/../include -fno-common -DPIC -o .libs/sendmsg.o /opt/gcc/work/libobjc/sendmsg.c: In function '__objc_word_forward': /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: in check_rtl, at lra.c:2034 } ^ /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: Abort trap xgcc: internal compiler error: Abort trap (program cc1) ./libtool: line 1147: 70450 Abort trap /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ -B/opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/bin/ -B/opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/lib/ -isystem /opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/include -isystem /opt/gcc/gcc4.9w/x86_64-apple-darwin10.8.0/sys-include /opt/gcc/work/libobjc/sendmsg.c -c -I. -I/opt/gcc/work/libobjc -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing -fexceptions -I/opt/gcc/work/libobjc/../gcc -I/opt/gcc/work/libobjc/../gcc/config -I../.././gcc -I/opt/gcc/work/libobjc/../libgcc -I../libgcc -I/opt/gcc/work/libobjc/../include -fno-common -DPIC -o .libs/sendmsg.o make[2]: *** [sendmsg.lo] Error 1 make[1]: *** [all-target-libobjc] Error 2 ... This can be reproduced with the attached preprocessed file without option: [macbook] f90/bug% gcc49 -c sendmsg.i /opt/gcc/work/libobjc/sendmsg.c: In function '__objc_word_forward': /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: in check_rtl, at lra.c:2034 } ^ /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: Abort trap gcc49: internal compiler error: Abort trap (program cc1) Abort If gcc is configured with --enable-checking=release, the ICE is [macbook] f90/bug% /opt/gcc/gcc4.9p-201916/bin/gcc -c sendmsg.i /opt/gcc/work/libobjc/sendmsg.c: In function '__objc_word_forward': /opt/gcc/work/libobjc/sendmsg.c:848:1: error: insn does not satisfy its constraints: } ^ (insn 112 44 45 2 (set (reg:TI 45 xmm8 [89]) (reg:TI 53 )) /opt/gcc/work/libobjc/sendmsg.c:842 84 {*movti_internal} (expr_list:REG_DEAD (reg:TI 53 ) (nil))) /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: in extract_constrain_insn_cached, at recog.c:2073 /opt/gcc/work/libobjc/sendmsg.c:848:1: internal compiler error: Abort trap gcc: internal compiler error: Abort trap (program cc1) Abort The file compiles at r201908.
confirmed on x86_64-darwin12 @r202068
note this *breaks bootstrap* for the normal language set. reduced testcase: int foo (int a, ...) { void *args; args = __builtin_apply_args (); return 0; } /src/test/pr58269.c:7:1: internal compiler error: in check_rtl, at lra.c:2034
bt #0 0x0000000100d7805a in internal_error (gmsgid=0x404 <Address 0x404 out of bounds>) at /src/gcc-live-trunk/gcc/diagnostic.c:1120 #1 0x0000000100d78266 in fancy_abort (file=Could not find the frame base for "_Z11fancy_abortPKciS0_". ) at /src/gcc-live-trunk/gcc/diagnostic.c:1180 #2 0x00000001007e3f70 in check_rtl (final_p=true) at /src/gcc-live-trunk/gcc/lra.c:2034 #3 0x00000001007e49dd in lra (f=0x0) at /src/gcc-live-trunk/gcc/lra.c:2426 #4 0x000000010078da96 in do_reload () at /src/gcc-live-trunk/gcc/ira.c:4689 #5 0x000000010078dd4f in rest_of_handle_reload () at /src/gcc-live-trunk/gcc/ira.c:4818 #6 0x000000010078dd9f in execute (this=0x141e17400) at /src/gcc-live-trunk/gcc/ira.c:4847 #7 0x000000010089bbce in execute_one_pass (pass=0x141e17400) at /src/gcc-live-trunk/gcc/passes.c:2201 #8 0x000000010089be07 in execute_pass_list (pass=0x141e17400) at /src/gcc-live-trunk/gcc/passes.c:2253 #9 0x000000010089be38 in execute_pass_list (pass=0x141e16320) at /src/gcc-live-trunk/gcc/passes.c:2254 #10 0x00000001004944d1 in expand_function (node=0x142c0bd10) at /src/gcc-live-trunk/gcc/cgraphunit.c:1690 #11 0x0000000100494d41 in output_in_order () at /src/gcc-live-trunk/gcc/cgraphunit.c:1884 #12 0x0000000100495562 in compile () at /src/gcc-live-trunk/gcc/cgraphunit.c:2127 #13 0x000000010049570f in finalize_compilation_unit () at /src/gcc-live-trunk/gcc/cgraphunit.c:2209 #14 0x00000001000268d5 in c_write_global_declarations () at /src/gcc-live-trunk/gcc/c/c-decl.c:10125 #15 0x00000001009ab4ee in compile_file () at /src/gcc-live-trunk/gcc/toplev.c:560 #16 0x00000001009adcfb in do_compile () at /src/gcc-live-trunk/gcc/toplev.c:1878 #17 0x00000001009adead in toplev_main (argc=14, argv=0x7fff5fbffa00) at /src/gcc-live-trunk/gcc/toplev.c:1954 #18 0x0000000100d6106b in main (argc=14, argv=0x7fff5fbffa00) at /src/gcc-live-trunk/gcc/main.c:36
Created attachment 30736 [details] initial fix AFAICT, the problem here is that "TARGET_SSE && SSE_REGNO_P (regno)" now produces a different answer from pre-201915. So, the patch attached is a necessary (but not proven to be sufficient) fix. We need to audit all uses of SSE_REGNO_P () for darwin (at least). AFAIU, the x86_64 Darwin ABI is the same as the linux/system V - so we should be able to remove special-casing in some places (providing the SSE_REGPARM_MAX values are the Right Fix and correctly specified). I checked the Darwin x86_32 ABI info (briefly) and ISTM that the values for max call arg usage of MMX and SSE regs in i386.h are right, so perhaps we can remove more special-casing there too (not touched so far). Will try some additional tests later - and I'd welcome Mike's PoV here on how we prove "sufficient".
With the patch in comment #4 (and the one in pr58239, comment #14) on top of revision 202144, I have successfully bootstrapped with all languages but go on x86_64-apple-darwin10. Note that the reported ICE occurs only for the 64 bit mode and it break all the test in the suite that call __builtin_apply_args, gcc.target/i386/avx-vzeroupper-27.c with the reported ICE and the others with /opt/gcc/work/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c: In function 'bar': /opt/gcc/work/gcc/testsuite/gcc.target/i386/builtin-apply-mmx.c:35:1: internal compiler error: in assign_by_spills, at lra-assigns.c:1281 Thanks for the patch.
- || (TARGET_SSE && SSE_REGNO_P (regno) && !fixed_regs[regno])); + || (TARGET_SSE && SSE_REGNO_P (regno) + && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX) + && !fixed_regs[regno])); Those changes are not needed. If TARGET_64BIT is fasle all sse registers except xmm0-xmm7 should be fixed. Correct fix is index 0f4edb3..44b4b16 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -4231,10 +4231,10 @@ ix86_conditional_register_usage (void) /* If AVX512F is disabled, squash the registers. */ if (! TARGET_AVX512F) { - for (i = FIRST_EXT_REX_SSE_REG; i < LAST_EXT_REX_SSE_REG; i++) + for (i = FIRST_EXT_REX_SSE_REG; i <= LAST_EXT_REX_SSE_REG; i++) fixed_regs[i] = call_used_regs[i] = 1, reg_names[i] = ""; - for (i = FIRST_MASK_REG; i < LAST_MASK_REG; i++) + for (i = FIRST_MASK_REG; i <= LAST_MASK_REG; i++) fixed_regs[i] = call_used_regs[i] = 1, reg_names[i] = ""; } } - if (TARGET_MACHO) - { - if (SSE_REGNO_P (regno) && TARGET_SSE) - return true; - } - else - { - if (TARGET_SSE && SSE_REGNO_P (regno) - && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) - return true; - } + if (TARGET_SSE && SSE_REGNO_P (regno) + && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) + return true; Looks like this will break ABI. Before we returned true for e. g. xmm10. I couldn't find Darwin ABI to check which behaivor is correct. If we want to keep current behaivor something like index 0f4edb3..a603167 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5708,7 +5708,8 @@ ix86_function_arg_regno_p (int regno) if (TARGET_MACHO) { - if (SSE_REGNO_P (regno) && TARGET_SSE) + if (SSE_REGNO_P (regno) && TARGET_SSE + && ! EXT_REX_SSE_REGNO_P (regno)) return true; } else Should work.
(In reply to tocarip.intel from comment #6) > - || (TARGET_SSE && SSE_REGNO_P (regno) && > Those changes are not needed. If TARGET_64BIT is fasle all sse registers > except xmm0-xmm7 should be fixed. Correct fix is <snip> > Looks like this will break ABI. Before we returned true for e. g. xmm10. indeed, that was worrying me too. > I couldn't find Darwin ABI to check which behaivor is correct. The ABI for [x86_64] Darwin *should be* the same as "System V Application Binary Interface AMD64 Architecture Processor Supplement Draft Version 0.99.5" it is possible that: (a) GCC has been broken a while and this is just not covered by the test-suite. (b) the system ABI has deviated from the referenced document. However - regardless of the doc, the system ABI is effectively defined by Apple's GCC-4.2.1 (or successor clang, where that is not the system default). > If we want to keep current behaivor something like <snip> > Should work. I will apply your revised patch (and keep the second amendment in reserve) and do some compat tests to find out what we need to do to be compliant with the system thanks for the patch, iain.
Author: kyukhin Date: Fri Sep 6 10:36:30 2013 New Revision: 202318 URL: http://gcc.gnu.org/viewcvs?rev=202318&root=gcc&view=rev Log: PR target/58269 * config/i386/i386.c (ix86_conditional_register_usage): Proper initialize extended SSE registers. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c
patch for the remainder of the fix posted at: http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00384.html
My x86_64-linux builds too are broken in libobj/sendmsg.c. Thus the issue isn't limited to *-darwin.
(In reply to Paolo Carlini from comment #10) > My x86_64-linux builds too are broken in libobj/sendmsg.c. Thus the issue > isn't limited to *-darwin. hmm there appears to be a second issue - also showing on Darwin (perhaps related to 202286) - my test was against 202275.
Yes, confirmed that on x86_64-linux r202286 is the culprit.
> Yes, confirmed that on x86_64-linux r202286 is the culprit. See pr58139 comments #6 to #11. I have successfully bootstrapped r202312 on x86_64-apple-darwin10 with the following patch: --- /opt/gcc/_clean/gcc/config/i386/i386.c 2013-08-28 18:59:22.000000000 +0200 +++ /opt/gcc/work/gcc/config/i386/i386.c 2013-09-06 10:46:46.000000000 +0200 @@ -4218,7 +4218,7 @@ ix86_conditional_register_usage (void) /* If AVX512F is disabled, squash the registers. */ if (! TARGET_AVX512F) - for (i = FIRST_EXT_REX_SSE_REG; i < LAST_EXT_REX_SSE_REG; i++) + for (i = FIRST_EXT_REX_SSE_REG; i <= LAST_EXT_REX_SSE_REG; i++) fixed_regs[i] = call_used_regs[i] = 1, reg_names[i] = ""; } @@ -5708,7 +5708,8 @@ ix86_function_arg_regno_p (int regno) if (TARGET_MACHO) { - if (SSE_REGNO_P (regno) && TARGET_SSE) + if (SSE_REGNO_P (regno) && TARGET_SSE + && ! EXT_REX_SSE_REGNO_P (regno)) return true; } else @@ -34466,7 +34467,7 @@ ix86_hard_regno_mode_ok (int regno, enum /* OImode move is available only when AVX is enabled. */ return ((TARGET_AVX && mode == OImode) - || VALID_AVX256_REG_MODE (mode) + || (TARGET_AVX && VALID_AVX256_REG_MODE (mode)) || VALID_SSE_REG_MODE (mode) || VALID_SSE2_REG_MODE (mode) || VALID_MMX_REG_MODE (mode) Note that the first hunk is r202318 and that without the second hunk, bootstrap fails with Comparing stages 2 and 3 warning: gcc/cc1-checksum.o differs warning: gcc/cc1obj-checksum.o differs warning: gcc/cc1objplus-checksum.o differs warning: gcc/cc1plus-checksum.o differs Bootstrap comparison failure! libiberty/md5.o differs libiberty/regex.o differs
(In reply to Dominique d'Humieres from comment #13) > > Yes, confirmed that on x86_64-linux r202286 is the culprit. > > See pr58139 comments #6 to #11. > @@ -34466,7 +34467,7 @@ ix86_hard_regno_mode_ok (int regno, enum > > /* OImode move is available only when AVX is enabled. */ > return ((TARGET_AVX && mode == OImode) > - || VALID_AVX256_REG_MODE (mode) > + || (TARGET_AVX && VALID_AVX256_REG_MODE (mode)) > || VALID_SSE_REG_MODE (mode) > || VALID_SSE2_REG_MODE (mode) > || VALID_MMX_REG_MODE (mode) > assuming that the patch above is applied to deal with pr58139, Are you saying that: - if (TARGET_MACHO) - { - if (SSE_REGNO_P (regno) && TARGET_SSE) - return true; - } - else - { - if (TARGET_SSE && SSE_REGNO_P (regno) - && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) - return true; - } + if (TARGET_SSE && SSE_REGNO_P (regno) + && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) + return true; gives a compare fail for you?
(In reply to Iain Sandoe from comment #14) > assuming that the patch above is applied to deal with pr58139, Indeed! > Are you saying that: > - if (TARGET_MACHO) > - { > - if (SSE_REGNO_P (regno) && TARGET_SSE) > - return true; > - } > - else > - { > - if (TARGET_SSE && SSE_REGNO_P (regno) > - && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) > - return true; > - } > + if (TARGET_SSE && SSE_REGNO_P (regno) > + && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) > + return true; > gives a compare fail for you? No: I did not test it although the initial fix worked for me). The comparison failures occur with r202318 and the patch for pr58139 only. These failures are fixed by the patch --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5708,7 +5708,8 @@ ix86_function_arg_regno_p (int regno) if (TARGET_MACHO) { - if (SSE_REGNO_P (regno) && TARGET_SSE) + if (SSE_REGNO_P (regno) && TARGET_SSE + && ! EXT_REX_SSE_REGNO_P (regno)) return true; } else from comment #6.
Trunk still ICEs on x86_64-apple-darwin12... /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20130906/libobjc/sendmsg.c:848:1: internal compiler error: in check_rtl, at lra.c:2034 } ^ using... r202335 | hubicka | 2013-09-06 10:39:17 -0400 (Fri, 06 Sep 2013) | 3 lines * i386.c (ix86_hard_regno_mode_ok): AVX modes are valid only when AVX is enabled.
(In reply to Jack Howarth from comment #16) > Trunk still ICEs on x86_64-apple-darwin12... > > /sw/src/fink.build/gcc49-4.9.0-1000/gcc-4.9-20130906/libobjc/sendmsg.c:848:1: > internal compiler error: in check_rtl, at lra.c:2034 > } > ^ > using... > > r202335 | hubicka | 2013-09-06 10:39:17 -0400 (Fri, 06 Sep 2013) | 3 lines > > * i386.c (ix86_hard_regno_mode_ok): AVX modes are valid only when > > AVX is enabled. I have 202322 built with /* OImode move is available only when AVX is enabled. */ return ((TARGET_AVX && mode == OImode) - || VALID_AVX256_REG_MODE (mode) + || (TARGET_AVX && VALID_AVX256_REG_MODE (mode)) || VALID_SSE_REG_MODE (mode) || VALID_SSE2_REG_MODE (mode) || VALID_MMX_REG_MODE (mode) and - if (TARGET_MACHO) - { - if (SSE_REGNO_P (regno) && TARGET_SSE) - return true; - } - else - { - if (TARGET_SSE && SSE_REGNO_P (regno) - && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) - return true; - } + if (TARGET_SSE && SSE_REGNO_P (regno) + && (regno < FIRST_SSE_REG + SSE_REGPARM_MAX)) + return true; it bootstrapped successfully and is in testing at present.
On Sep 6, 2013, at 8:43 AM, howarth at nitro dot med.uc.edu <gcc-bugzilla@gcc.gnu.org> wrote: > * i386.c (ix86_hard_regno_mode_ok): AVX modes are valid only when > AVX is enabled. llvm has: // The first 8 512-bit vector arguments are passed in ZMM registers. CCIfNotVarArg<CCIfType<[v16i32, v8i64, v16f32, v8f64], CCIfSubtarget<"hasAVX512()", CCAssignToReg<[ZMM0, ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6, ZMM7]>>>>, just after the sse registers… conceptually, I wonder if gcc is missing that.
(In reply to Mike Stump from comment #18) > On Sep 6, 2013, at 8:43 AM, howarth at nitro dot med.uc.edu > <gcc-bugzilla@gcc.gnu.org> wrote: > > * i386.c (ix86_hard_regno_mode_ok): AVX modes are valid only when > > AVX is enabled. > > llvm has: > > // The first 8 512-bit vector arguments are passed in ZMM registers. > CCIfNotVarArg<CCIfType<[v16i32, v8i64, v16f32, v8f64], > CCIfSubtarget<"hasAVX512()", > CCAssignToReg<[ZMM0, ZMM1, ZMM2, ZMM3, ZMM4, ZMM5, ZMM6, > ZMM7]>>>>, > > just after the sse registers… conceptually, I wonder if gcc is missing that. On the basis that clang (Darwin11, Darwin12) defines the ABI - we should see about this. Presumably, this should be disabled for OS versions where gcc-4.2/gcc-4.0 are the "system compiler". As of now, the documentation does not refer to this - the web page still points to the older psABI. Is there an official update to the System V psABI covering these regs?
(In reply to Iain Sandoe from comment #19) The full commit where this was added to llvm is at http://permalink.gmane.org/gmane.comp.compilers.llvm.cvs/153081 and references http://software.intel.com/en-us/intel-isa-extensions (and I assume http://download-software.intel.com/sites/default/files/319433-015.pdf).
Don't know… I'd assume there exists a paper somewhere that says it. :-)
Author: iains Date: Sat Sep 14 11:09:55 2013 New Revision: 202590 URL: http://gcc.gnu.org/viewcvs?rev=202590&root=gcc&view=rev Log: gcc: PR target/58269 config/i386/i386.c (ix86_function_arg_regno_p): Make Darwin use the xmm register set described in the psABI. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c
Fixed. Thanks fro the report and the fix guys.