We recently added the predicate simplifier pass to llvm-gcc. See gcc/llvm-backend.cpp Sometime after 10/21, llvm-gcc bootstrapping broke. There were only a handful of changes. After eliminating the possibility of Chris' changes may have broke it, I tried disabling the predsimplfier pass. That did the trick. Nick, please do a llvm-gcc build: svn co ... llvm-gcc cd llvm-gcc cvs co llvm mkdir -p build/obj build/dst build/sym gnumake install RC_OS=macos RC_ARCHS='i386 ppc' TARGETS='i386 ppc' SRCROOT=`pwd` OBJROOT=`pwd`/build/obj DSTROOT=`pwd`/build/dst SYMROOT=`pwd`/build/sym The failure looks like this: ./xgcc -B./ -B/usr/local/llvm-gcc-install/i686-apple-darwin8/bin/ -isystem /usr/local/llvm-gcc-install/i686-apple-darwin8/include -isystem /usr/local/llvm-gcc-install/i686-apple-darwin8/sys-include -L/Volumes/\ Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/obj-i686-i686/gcc/../ld -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fP\ IC -pipe -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/\ build/obj/src/gcc/. -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/../include -I./../intl -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/../libcpp/include \ -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/llvm/include -I/Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/obj-llvm/include -DL_muldi3 -c /Volumes/Wildlings/echeng/S\ UBMISSIONS/llvm-submission/build/obj/src/gcc/libgcc2.c -o libgcc/./_muldi3.o In file included from /Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/tsystem.h:47, from /Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/libgcc2.c:41: ./include/stddef.h:152: error: storage class specified for parameter 'ptrdiff_t' ./include/stddef.h:214: error: storage class specified for parameter 'size_t' ./include/stddef.h:326: error: storage class specified for parameter 'wchar_t' In file included from /Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/tsystem.h:87, from /Volumes/Wildlings/echeng/SUBMISSIONS/llvm-submission/build/obj/src/gcc/libgcc2.c:41: ./include/stdarg.h:43: error: storage class specified for parameter '__gnuc_va_list' ./include/stdarg.h:105: error: syntax error before 'va_list' ...
I have verified that reverting back to 1.24 does not fix the bug. It does, however, change the failure mode.
Hm. My problem is, I just did an llvm-gcc bootstrap build last night. It works for me. Of course, I'm running x86/linux, which is probably the major difference. What I need here is a testcase. Do you have *any* other examples of code being miscompiled by predsimplify? It would be much easier than trying to debug GCC. Otherwise, someone's going to have to isolate the testcase out of gcc; compile half the code with LLVM, half the code with GCC and link. See if the bug is there, rinse & repeat. Getting it down to the .c file being miscompiled is good enough for me. Alternately, you could try narrowing down the optzns in predsimplify instead. The major change from 1.23 and 1.24 was the workings of resolve. Try removing the call to "resolve" from "addImpliedProperties". If the bug goes away, then one of the transforms in resolve() is the culprit, otherwise it's either addImpliedProperties or one of the Forwards::visit* methods. If you can narrow it down for me, I can take it from there...
To be specific, when following the instructions, I get: $ make install RC_OS=macos RC_ARCHS='i386 ppc' TARGETS='i386 ppc' SRCROOT=`pwd` OBJROOT=`pwd`/build/obj DSTROOT=`pwd`/build/dst SYMROOT=`pwd`/build/sym GNUmakefile:16: /CoreOS/Standard/Standard.make: No such file or directory make: *** No rule to make target `/CoreOS/Standard/Standard.make'. Stop.
I reverted the predsimplifier back to 1.21. Something in r1.22 broke it. I don't follow the logic well enough to understand what is going on. -Chris
Chris, could you start with r1.24 and #if 0 away the code in case Instruction:Xor and replace it with just "break;" ? Does that remove the problem?
Ok, I can reproduce this bug on x86/linux by running "make cleanstrap" (thanks Chris for the clue). I'll try disabling parts of predsimplify until it works.
I've found and fixed a couple of miscompile bugs, but this bug remains. It goes away if I remove the "case Instruction::Or" from addImpliedProperties. I can further say that it's not caused by the bool type. What I'm doing now is printing out a message when this optimization occurs. I'm going to use that to narrow down the list of .c files that I need to binary search on. Regardless, this is going to take a few days.
I have a predicate simplifier partial rewrite which fixes this problem. I'm hoping to land the change this upcoming week. Thanks for your patience...
New code has been checked in. I can bootstrap with predsimplify enabled. If you can't, please reopen this bug.