[cfe-dev] [RFC] A proposal for #pragma optnone

Dario Domizioli dario.domizioli at gmail.com
Mon Apr 28 07:43:39 PDT 2014


> Why do you want to invent a similar, but only slightly difference
mechanism to disable optimizations?

The short answer is that our underlying infrastructure in Clang/LLVM is
different and our mechanism has to be slightly different.

Essentially, 'optnone' does not in fact implement the full feature that
"#pragma optimize" is supposed to implement.
A way to control optimization levels per-function has been proposed several
times in the past (see for example
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-April/061527.html ), but
the community has never reached a consensus on the idea; I think last time
the problem was that there were design issues with the PassManager in LLVM
which at the time was being redesigned (but as far as I know even the
redesigned version does not allow per-function control on optimizations).
The only consensus that was reached was to implement a function attribute
to disable local optimizations for this specific use case - i.e. 'optnone'.
Therefore, providing a pragma like "#pragma gcc optimize" that however
deals with only one case (i.e. optimization level zero) would cause
confusion. Ideally if we want to have such pragma we should implement the
full feature, but there is no consensus on that at the moment, so we have
to use a different approach.

In terms of what our users would do, they already abstract this
functionality behind macros, as explained in the slides I referenced
earlier. The important thing for them is that the feature is range-based
rather than attribute-based, so they can #define the actual syntax with
macros that can be used in the same way as with the other compilers.

I agree that the best solution would be to implement the full #pragma
optimize feature. We just don't want to restart the full debate (with the
risk of not reaching consensus again), and we'd rather settle for the
low-hanging fruit in the short term.
 As we note in the spec, if we ever implement the full #pragma optimize in
clang/LLVM then #pragma optnone will just become obsolete and deprecated.
So this proposal does not hinder any future work on the full #pragma
optimize feature.

Cheers,
    Dario Domizioli
    SN Systems - Sony Computer Entertainment Group






On 28 April 2014 14:37, "C. Bergström" <cbergstrom at pathscale.com> wrote:

> On 04/28/14 08:06 PM, Dario Domizioli wrote:
>
>>
>> The goal of this feature would be to behave in a similar way to "#pragma
>> optimize off" in Visual Studio, or "#pragma GCC optimize (0)" in gcc.
>>
>>  Why do you want to invent a similar, but only slightly difference
> mechanism to disable optimizations? Why not adopt something which is
> already familiar to a user community.
>
> Alternatively - if you insist yet another pragma is necessary - could an
> "alias" be made so that some of the same mechanics can be leveraged to
> implement the duplicate behavior?
>
> My personal opinion is that the exact wording of both the gcc and msvc are
> more "clean" than this possibly confusing double negative..
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140428/6ec6a502/attachment.html>


More information about the cfe-dev mailing list