[cfe-dev] selective/fine grained optimizations control

Eli Friedman eli.friedman at gmail.com
Wed Aug 28 09:45:26 PDT 2013


On Wed, Aug 28, 2013 at 12:50 AM, Domagoj Saric <
domagoj.saric at littleendian.com> wrote:

>
> 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.
>
> 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.
>
> I did find this
> http://stackoverflow.com/**questions/15548023/clang-**optimization-levels<http://stackoverflow.com/questions/15548023/clang-optimization-levels>
> but it didn't help: I tried -O0 -mllvm -sroa and got:
> clang (LLVM option parsing): Unknown command line argument '-sroa'.  Try:
> 'clang (LLVM option parsing) -help'
> clang (LLVM option parsing): Did you mean '-help'?
>
>
> Is there any other way to achieve fine grained optimizations control?
>
>
> clang intentionally doesn't expose fine-grained control over optimization
passes.

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.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130828/d279dd0d/attachment.html>


More information about the cfe-dev mailing list