[LLVMdev] [cfe-dev] [PROPOSAL] per-function optimization level control

Andrea_DiBiagio at sn.scee.net Andrea_DiBiagio at sn.scee.net
Wed Apr 24 08:36:13 PDT 2013


Hi,

> Especially since we have support for per function code gen attributes 
now.

I think having function attributes would certainly be useful.
GCC for example provide support for both pragma and function attributes to 
control per-function optimizations. Also, the effect of using pragma 
optimize to control optimizations on a per-function basis is equivalent in 
GCC to specifying the 'optimize' function attribute (followed by a string 
describing an optimization option) for that function.

In my opinion we could also have both pragma and function attributes: 
having a pragma does not mean that we cannot have function attributes.

A very common pattern that we see in our customers' code is a unity build. 
 That is, in order to reduce debug data overhead, and to improve link-time 
they'll group large numbers of their source files together into single 
"unity files".  e.g.

// ------------------
// unity01.cpp
#include <physics.cpp>
#include <textures.cpp>
#include <renderer.cpp>
etc.
// ------------------

In some cases if they've narrowed down a problem, they'll want to debug 
individual functions inside one of these files in which case an attribute 
may be enough. 
However, if they just know, for example, that they have a problem 
somewhere in their texture code they'll often want to do something like 
this:

// ------------------
// unity01.cpp
#include <physics.cpp>

#pragma clang optimize push
#pragma clang optimize "O0" 
#include <textures.cpp>
#pragma clang optimize pop 

#include <renderer.cpp>
etc.
// ------------------

Thanks,
-- Andrea DiBiagio


**********************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify postmaster at scee.net
This footnote also confirms that this email message has been checked for 
all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United 
Kingdom
Registered in England: 3277793
**********************************************************************

P Please consider the environment before printing this e-mail



More information about the llvm-dev mailing list