<div dir="ltr">On Wed, Apr 24, 2013 at 6:00 AM,  <span dir="ltr"><<a href="mailto:Andrea_DiBiagio@sn.scee.net" target="_blank">Andrea_DiBiagio@sn.scee.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
<br>
We've had a high priority feature request from a number of our customers<br>
to<br>
provide per-function optimization in our Clang/LLVM compiler.<br>
I would be interested in working with the community to implement this.<br>
The idea is to allow the optimization level to be overridden<br>
for specific functions.<br>
<br>
The rest of this proposal is organized as follows:<br>
 - Section 1. describes this new feature and explains why and when<br>
   per-function optimization options are useful;<br>
 - Sections 2. and 3. describe how the optimizer could be adapted/changed<br>
   to allow the definition of per-function optimizations;<br>
 - Section 4. tries to outline a possible workflow for implementing this<br>
   new feature.<br>
<br>
I am looking for any feedback or suggestions etc.<br>
<br>
Thanks!<br>
Andrea Di Biagio<br>
SN Systems Ltd.<br>
<a href="http://www.snsys.com" target="_blank">http://www.snsys.com</a><br>
<br>
1. Description<br>
==============<br>
The idea is to add pragmas to control the optimization level on functions.<br>
<br>
A similar approach has been implemented by GCC as well.<br>
Since GCC 4.4, new function specific option pragmas have been added to<br>
allow<br>
users to set the optimization level on a per function basis.<br>
<br>
<a href="http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html" target="_blank">http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html</a><br>
describes the pragmas as<br>
  #pragma GCC optimize ("string")<br>
  #pragma GCC push_options<br>
  #pragma GCC pop_options<br>
  #pragma GCC reset_options<br>
<br>
Instead of imitating GCC's syntax, I think it would be better to use a<br>
syntax<br>
consistent with existing pragma clang diagnostics:<br>
<br>
  #pragma clang optimize push<br>
  #pragma clang optimize "string"<br>
  #pragma clang optimize pop<br></blockquote><div><br></div><div>Since the intent is to provide overrides on a per-function basis, have you considered using a function attribute instead of a pragma?</div></div></div></div>