PR40011 -fwhole-file problems

Andrew Pinski pinskia@gmail.com
Wed Jun 3 03:38:00 GMT 2009


2009/6/1 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.

It is inlined at -O2 for 4.4.0 20080525, I don't have a newer version
on this machine to try.  Try to dump with -fdump-tree-all-uid and you
might see that the foo2 are different variables which might be the
cause of your issue.  Is foo2 in this case supposed to be the same
variable?

Thanks,
Andrew Pinski



More information about the Fortran mailing list