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

Dallman, John john.dallman at siemens.com
Thu May 1 04:48:58 PDT 2014


On 01 May 2014 Renato Golinwrote:
> On 1 May 2014 12:09, Dario Domizioli <dario.domizioli at gmail.com> wrote:
> > Yours and Alex's suggestion of "#pragma clang optimize on/off" (i.e.
> > removing the double negative) has also the benefit of sounding similar
> > to MSVC which is what our multi-platform users will see the most.

This seems like the best method to me. I use this kind of pragma reasonably
frequently when chasing down optimizer bugs, but don't regard it as something
that I can put into production code. So cross-platform compatibility isn't
important to me, but avoiding confusion is always worthwhile.

> Side question, wouldn't supporting the full MSVC syntax help your users
> to have only one version?

The Microsoft syntax is based on the architecture of their compiler, in
terms of the kinds of optimisation that can be turned on and off individually.
Assuming that it can be reproduced in a different compiler without subtle
and confusing differences seems unwise: if it looks just like the Microsoft
pragma, people will assume it has identical effects.

The Microsoft pragma is documented here:
http://msdn.microsoft.com/en-us/library/chh3fb0k.aspx

Other compilers I've done this with have all had different syntaxes:

HP-UX older compilers had

#pragma optimize ON|OFF

Modern HP-UX compilers have:

#pragma optimize 0|1|2|3|INITIAL ((returns the level to the command line setting))

Solaris compilers have:

#pragma opt 0|1|2|3|4|5 ( function-name )

AIX compilers have:

#pragma option_override ( function-name, "opt(level,0|1|2)" )

--
John Dallman
Technology & Innovation

Siemens Industry Sector
Siemens Industry Software Limited
Francis House, 112 Hills Road,
Cambridge CB2 1DP, United Kingdom
Tel.      :+44 (1223) 371554
Fax      :+44 (1223) 371700
john.dallman at siemens.com
www.siemens.com/plm


-----------------
Siemens Industry Software Limited is a limited company registered in England and Wales.
Registered number: 3476850.
Registered office: Faraday House, Sir William Siemens Square, Frimley, Surrey, GU16 8QD.




More information about the cfe-dev mailing list