[LLVMdev] Optimization Help
Chris Lattner
clattner at apple.com
Mon Jan 11 08:54:36 PST 2010
On Jan 11, 2010, at 5:07 AM, Curtis Jones wrote:
> I am working on a program which links with the FTDI USB driver (ftd2xx.dylib). Prior to a couple of hours ago I had only worked with Debug builds of my code (no compiler optimizations). In testing a production build, I found that using anything other than -O0 results in the FTDI driver returning bad data; just a lot of zeroes. I tested and re-tested to make sure that changing just that one option was the issue. And I have absolutely no idea how to go about figuring out what the actual issue is; or what a reasonable remedy is.
>
> If the likely cause isn't obvious based on the little bit of information I've provided, please tell me what details I can provide that would be useful. I don't know where to begin.
It's impossible to tell without more information, but the most likely cause of this is if your code has undefined behavior. For example, if it uses variables without initializing them, reads off the end of an array, etc, the code may significantly change behavior after optimization. Tools like valgrind are often helpful tracking these sorts of things down. If you're building with clang head, you can try the experimental -fcatch-undefined-behavior flag.
-Chris
More information about the llvm-dev
mailing list