<div dir="ltr">On Wed, Aug 28, 2013 at 12:50 AM, Domagoj Saric <span dir="ltr"><<a href="mailto:domagoj.saric@littleendian.com" target="_blank">domagoj.saric@littleendian.com</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
We have a project which Clang miscompiles in release builds (in short "the GUI shows up empty"). "It all worked fine" up until and including Xcode 4.2, with all later versions (of Xcode and consequently of Clang shipped with it) this bug manifests itself. As we officially switched to Xcode 4.6.3 I have to find a way to workaround or fix this problem.<br>

<br>
The bug manifests already with -O1 while it does not with -O0 so I need a way to selectively enable or disable optimizations turned on at O1. GCC nicely documents which optimizations are turned on by individual -O levels and offers the various -fno-* options for fine grained control but unfortunately Clang does not actually support GCC's command line options other than the basic ones.<br>

<br>
I did find this<br>
<a href="http://stackoverflow.com/questions/15548023/clang-optimization-levels" target="_blank">http://stackoverflow.com/<u></u>questions/15548023/clang-<u></u>optimization-levels</a><br>
but it didn't help: I tried -O0 -mllvm -sroa and got:<br>
clang (LLVM option parsing): Unknown command line argument '-sroa'.  Try: 'clang (LLVM option parsing) -help'<br>
clang (LLVM option parsing): Did you mean '-help'?<br>
<br>
<br>
Is there any other way to achieve fine grained optimizations control?<span class="HOEnZb"><font color="#888888"><br>
<br><br></font></span></blockquote><div>clang intentionally doesn't expose fine-grained control over optimization passes.<br><br></div><div>It's probably a better idea to figure out which file is getting incorrectly compiled, and change the optimization level for that file,instead of messing with the optimization levels for the whole project.  Also, this sort of issue is almost always caused by code that has undefined behavior, not by a bug in the compiler.<br>
<br></div><div>-Eli<br></div></div></div></div>