[LLVMdev] Major i386 optimization bug in Clang++?
baldrick at free.fr
Mon Oct 10 07:40:02 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.
try compiling with -m32. I suspect -arch doesn't mean what you think it means.
PS: I can't reproduce on a real 32 bit machine.
> Here is what you see if you compile the example with O2:
> $ /Developer/usr/bin/clang++ -arch i386 -o testLLVM testLLVM.cp -O2
> $ ./testLLVM
> 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.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev