[Patch, Fortran] Add -frecursive, imply it with -fopenmp, check for flag conflicts and update invoke.texi

Tobias Burnus burnus@net-b.de
Mon Aug 20 15:38:00 GMT 2007


:ADDPATCH fortran:

This patch supercedes the patch by Asher,
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00960.html
and by me
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00996.html

By default, gfortran currently puts local variables (with known bounds),
which are smaller than 32kbits, on the  stack, variables which are
bigger are marked as static. (And automatic variables etc. are allocated
on the heap.)

Some legacy applications imply SAVE without actually specifying it; in
this case -fno-automatic (or -fmax-stack-var-size=0) has to be used.

Other legacy applications call procedures recursively without using the
RECURSIVE attribute - or the recursion happens through the backdoor via
parallelization (OpenMP, but potentially also shared-memory MPI, Posix
Threads, ...). In this case the local variables of such procedures shall
not be in static memory.

Internally, gfortran uses gfc_option.flag_max_stack_var_size = -1 for
the latter, but since "fmax-stack-var-size=" is "UInteger" thus -1
cannot be set from the command line.

This patch introduces the option -frecursive to disable static memory
for local variables; makes -fopenmp imply -frecursive and adds a couple
of warning if conflicting options have been specified. The hierarchy of
the options is:

1. Implied: stack-var-size = 32 k (implied by the default
-fmax-stack-var-size= 32k and -fautomatic)
2. -fopenmp implies: stack-var-size=-1
3. Explicitly set -fmax-stack-var-size=<n>
4. -frecursive: stack-var-size=-1
5. -fno-automatic: stack-var-size=0

Regression tested on x86_64-unknown-linux-gnu and with "make info" and
"make pdf".
Ok for the trunk?

Tobias
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: recursive.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070820/e4000f47/attachment.ksh>


More information about the Fortran mailing list