On 7/26/07, Basile STARYNKEVITCH <[EMAIL PROTECTED]> wrote:
Rohit Arul Raj wrote:
> Hi all,
>
> I have 3 functions- fun1, fun2, fun3 in the same source file and i
> want to enable one or any of the gcc optimization pass to code in fun2
> only,
>
> 1. Is it possible to implement this using function attributes or #pragms's?


I believe that currently, tuning optimisation levels at a function granularity 
(or perhaps even smaller, like blocks) is
impossible in current GCC. I heard at the GCC summit (18th july 2007 at Ottawa) 
that it would be a desirable feature,
but I am not sure that someone is actively working on it.

So currently, the answer seems to be no.

>
As of now,
a) I have added target dependent function attributes for all
optimization levels in the backend.
b) In function execute_pass_list() i am having a condition check for
those function attributes,      if a valid optimization level is given
as a function attribute, the global variable optimize and
optimize_size are overridden for the current function. For other
functions, the global variables are restored to their initial values.

For a simple case- fun1, fun2, fun3, i gave function attribute O1 to
fun2, while the other 2 functions optimization was not enabled. The
only difference i found was that IPA passes were not run, other than
that the code was optimized for fun2.
I am yet to check how it affects other cases.

Is there any other better way of implementing this?


> 2. What will be its side-effects?

Apparently, one of the issues is that some optimising passes (or their 
combination) rely on some global variable, so it
is not a trivial job to tune optimisations at the function level.

But I may be wrong on both points.

--
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net | mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


Regards,
Rohit

Reply via email to