LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 966 - Turning on predicate simplifier pass breaks llvm-gcc bootstrapping
Summary: Turning on predicate simplifier pass breaks llvm-gcc bootstrapping
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Nick Lewycky
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2006-10-23 15:27 PDT by Evan Cheng
Modified: 2010-03-06 13:58 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evan Cheng 2006-10-23 15:27:38 PDT
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'
...
Comment 1 Chris Lattner 2006-10-23 17:11:37 PDT
I have verified that reverting back to 1.24 does not fix the bug.  It does, however, change the failure mode.
Comment 2 Nick Lewycky 2006-10-23 17:33:29 PDT
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...
Comment 3 Nick Lewycky 2006-10-23 18:50:33 PDT
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.
Comment 4 Chris Lattner 2006-10-23 19:37:08 PDT
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
Comment 5 Nick Lewycky 2006-10-23 20:00:47 PDT
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?
Comment 6 Nick Lewycky 2006-10-24 06:14:36 PDT
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.
Comment 7 Nick Lewycky 2006-10-26 18:42:30 PDT
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.
Comment 8 Nick Lewycky 2006-11-11 18:06:44 PST
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...
Comment 9 Nick Lewycky 2006-11-22 19:36:52 PST
New code has been checked in. I can bootstrap with predsimplify enabled. If you
can't, please reopen this bug.