Created attachment 35251 [details] snip of the build log I can't build anymore virtualbox with gcc 5-20150404-1 in experimental (medium) (debian experimental) gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 5-20150404-1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 5.0.0 20150404 (experimental) [trunk revision 221867] (Debian 5-20150404-1) attaching the build log, the build log2 with -Wall -Wextra -fno-strict-aliasing and the preprocessed source
Created attachment 35252 [details] log with -Wall -Wextra -fno-strict-aliasing -fwrapv
Created attachment 35253 [details] preprocessed source
markus@x4 tmp % cat t.ii int a; unsigned b; void VBoxNsxpXPTC_InvokeByIndex () { unsigned long *c = (unsigned long *) __builtin_alloca (b); a = *c; register int d asm("rdx") = ((int (*) (int, int, int, int, int, int)) 0)(0, 0, d, 0, 0, 0); } markus@x4 tmp % g++ -c t.ii t.ii: In function ‘void VBoxNsxpXPTC_InvokeByIndex()’: t.ii:10:1: error: unable to find a register to spill } ^ t.ii:10:1: error: this is the insn: (insn 10 37 11 2 (parallel [ (set (reg:DI 97) (udiv:DI (reg:DI 95) (reg:DI 107))) (set (reg:DI 108 [98]) (umod:DI (reg:DI 95) (reg:DI 107))) (clobber (reg:CC 17 flags)) ]) t.ii:6 352 {*udivmoddi4} (expr_list:REG_UNUSED (reg:DI 108 [98]) (expr_list:REG_DEAD (reg:DI 107) (expr_list:REG_DEAD (reg:DI 95) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil)))))) t.ii:10: confused by earlier errors, bailing out
I don't think this is a 5 Regression, even 4.6 ICEs for me.
Well, this testcase only ICEs with gcc-5: markus@x4 tmp % < foo.ii int a, b; unsigned c; static void invoke_copy_to_stack (unsigned long *p1, int, int) { for (; b;) if (a) *p1 = 0; } void VBoxNsxpXPTC_InvokeByIndex () { unsigned long *d = (unsigned long *) __builtin_alloca (c); invoke_copy_to_stack (d, 0, 0); register int e asm("rdx") = ((int (*) (int, int, int, int, int, int)) 0)(0, 0, e, 0, 0, 0); } markus@x4 tmp % g++ -O -c foo.ii foo.ii: In function ‘void VBoxNsxpXPTC_InvokeByIndex()’: foo.ii:18:1: error: unable to find a register to spill } ^ foo.ii:18:1: error: this is the insn: (insn 9 8 10 2 (parallel [ (set (reg:DI 98) (udiv:DI (reg:DI 96) (reg:DI 106))) (set (reg:DI 109 [99]) (umod:DI (reg:DI 96) (reg:DI 106))) (clobber (reg:CC 17 flags)) ]) foo.ii:14 352 {*udivmoddi4} (expr_list:REG_UNUSED (reg:DI 109 [99]) (expr_list:REG_DEAD (reg:DI 106) (expr_list:REG_DEAD (reg:DI 96) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil)))))) foo.ii:18: confused by earlier errors, bailing out
4.3 works for me so does 4.5.
gcc-4.9 combines udivmoddi4 to : (insn 30 5 8 2 (set (reg:DI 103) (const_int 16 [0x10])) pr65693.ii:6 -1 (nil)) [...] (insn 9 8 10 2 (parallel [ (set (reg:DI 94) (udiv:DI (reg:DI 92) (reg:DI 103))) (set (reg:DI 95) (umod:DI (reg:DI 92) (reg:DI 103))) (clobber (reg:CC 17 flags)) ]) pr65693.ii:6 348 {*udivmoddi4} (expr_list:REG_DEAD (reg:DI 103) (expr_list:REG_DEAD (reg:DI 92) (expr_list:REG_UNUSED (reg:DI 95) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil)))))) Trying 30 -> 9: ... Successfully matched this instruction: (set (reg:DI 94) (lshiftrt:DI (reg:DI 92) (const_int 4 [0x4]))) For some reason gcc-5 doesn't do this conversion anymore.
Nope, I can build on debian (I'm the maintainer BTW) with 4.9 successfully. https://buildd.debian.org/status/fetch.php?pkg=virtualbox&arch=amd64&ver=4.3.26-dfsg-1&stamp=1426696248 for now I forced gcc-4.9 as a gcc version and the build completes with no problems. This is why I think this is a gcc-5.0 specific regression. Also gcc 4.8 and 4.7 are fine (I maintain a backport on ubuntu too, and they all build correctly). This is a snapshot of virtualbox 5.0.0_BETA1, but the ICE occurs with virtualbox 4.3.26 and older releases (but *only* with gcc-5)
Started with r218248.
Hi @Markus, I'm *really* impressed about your efficiency. I reported the progresses on the vbox official mail list, thanks!
I see GCC not trying to throw away the useless arm of the parallel, just as comment 7 mentions. I wonder why that is, investigating. This isn't the root cause; it is just exposing a problem in the RA :-(
Well, the RA issue is hard to deal with, there is a local register var that uses a register some instruction needs while the local register is live. Anyway, this alloca/VLA division issue is what I meant to fix with PR65220, but here unfortunately the RTL cprop isn't performed because the function has a single basic block and for some reason RTL cprop doesn't perform even the local cprop subpass then. And, at combine time, combiner attempts to simplify the insn, so the *udivmod<mode>4_pow2 pattern no longer matches. One possibility to fix this would be to add *udivmod<mode>4_pow2_1 pattern that would just have the lshiftrt and and instructions in PARALLEL until reload, then split them.
Created attachment 35261 [details] gcc5-pr65693.patch Untested fix.
I sent a patch for the combine issue, http://gcc.gnu.org/ml/gcc-patches/2015-04/msg00359.html .
Author: segher Date: Wed Apr 8 22:52:24 2015 New Revision: 221937 URL: https://gcc.gnu.org/viewcvs?rev=221937&root=gcc&view=rev Log: PR rtl-optimization/65693 * combine.c (is_parallel_of_n_reg_sets): Change first argument from an rtx_insn * to an rtx. (try_combine): Adjust both callers. Use it once more. Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c
Author: jakub Date: Thu Apr 9 07:28:54 2015 New Revision: 221942 URL: https://gcc.gnu.org/viewcvs?rev=221942&root=gcc&view=rev Log: PR target/65693 * config/i386/i386.md (*udivmod<mode>4_pow2): Allow any pow2 integer in between 2 and 0x80000000U inclusive. * gcc.target/i386/pr65693.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr65693.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.md trunk/gcc/testsuite/ChangeLog
Author: segher Date: Thu Apr 9 14:37:14 2015 New Revision: 221951 URL: https://gcc.gnu.org/viewcvs?rev=221951&root=gcc&view=rev Log: PR rtl-optimization/65693 * combine.c (is_parallel_of_n_reg_sets): Move outside of #ifndef HAVE_cc0. Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c
Fixed on the trunk so far.
I tested a build with the patch https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=221937 and the build seems to have been successfully completed (I got some pedantic errors, but nothing spills related) thanks a lot to everybody for the support!