PR40011 -fwhole-file problems

Richard Guenther richard.guenther@gmail.com
Wed Jun 3 10:26:00 GMT 2009


2009/6/2 Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>:
>
> Hi,
>
> Paul Richard Thomas wrote:
>>
>> gfortran.dg/default_initialization_3.f90 fails at runtime at -O2.   I
>> have reduced it to expose the problem:
>
> ...
>>
>> Which looks fine.  At -O2, however, we get:
>>
>> func (integer(kind=4) & ivalue, struct myint & retval1, struct myint &
>> retval2)
>> {
>>  static struct myint foo2 = {.bar=77};
>>
>> <bb 2>:
>>  retval1_1(D)->bar = 42;
>>  *retval2_2(D) = foo2;
>>  foo2.bar = 999;
>>  return;
>>
>> }
>>
>>
>> ;; Function other (other_)
>>
>> other ()
>> {
>>  static struct myint foo2 = {.bar=77};
>>  static struct myint foo2 = {.bar=77};
>>  static struct myint foo2 = {.bar=77};
>
> 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.

The inliner is perfectly capable of inlining functions with static
variables.  Likely GFortran messes up the flags for the static
vars so they get copied during inlining (which is what you see above,
use -uid on the dump flag to see the DECL uids).

Richard.



More information about the Fortran mailing list