[LLVMdev] Major i386 optimization bug in Clang++?
timac at timac.org
Mon Oct 10 07:10:13 PDT 2011
I am currently making the transition from gcc 4.2 to clang for the projects (mostly C++) I am working on.
I think I discovered a major optimization bug in Clang++. I managed to create a simple (60 lines of code) test case which exhibits the issue.
When you compile this file for i386 with optimizations turned on (O2, O3 or Os), you get an unexpected result. When you compile it for x86_64, or for i386 with optimizations turned off (O0 or O1), you get the expected behavior. I can reproduce this issue with Clang shipping in Xcode 4.2 GM as well as the Clang binaries from LLVM 2.9 (http://llvm.org/releases/download.html#svn). The tests were made on a Mac running 10.7.1.
Here is what you see if you compile the example with O2:
$ /Developer/usr/bin/clang++ -arch i386 -o testLLVM testLLVM.cp -O2
Unexpected Value: 3222105416 (at index: 2)
Expected Value: 3 (at index: 2)
I haven't found any bugs similar in the LLVM bug database. It is a known issue? This looks like a major optimization issue which causes us to not be able to use Clang for our products.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2067 bytes
Desc: not available
More information about the llvm-dev