PR40011 -fwhole-file problems

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Tue Jun 2 21:00:00 GMT 2009


Andrew Pinski wrote:
> 2009/6/2 Paul Richard Thomas <paul.richard.thomas@gmail.com>:
>> Tobias,
>>
>>> This is the issue, apparently the optimizer can't handle inlining functions
>>> with static variables (SAVE in Fortran).  I verified with a C example that
>>> indeed functions with static variables are not inlined if they're called
>>> more than once.
> 
> Huh?  It works for me:
> int f(int g1, int b)
> {
>   static int g;
>   if (b) g = 1;
>   return g;
> }
> 
> int h(void)
> {
>   return f(1, 0);
> }
> 
> int j(int a, int b)
> {
>   return f(a, b);
> }

Ah, I hadn't checked with trunk, thanks.  Andrew, I guess Paul would 
appreciate to learn what is the magic incantation that's needed to get 
functions with static variables to be inlined correctly.  Do you know?

Cheers,
- Tobi



More information about the Fortran mailing list