[flang-commits] [PATCH] D139892: [flang] Submodules

vdonaldson via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Dec 12 16:14:27 PST 2022


vdonaldson created this revision.
vdonaldson added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
vdonaldson requested review of this revision.

A submodule is a program unit that may contain the implementions of procedures
declared in an ancestor module or submodule.

Processing for the equivalence groups and variables declared in a submodule
scope is similar to existing processing for the equivalence groups and
variables in module and procedure scopes. However, module and procedure scopes
are tied directly to code in the Pre-FIR Tree (PFT), whereas processing for a
submodule must have access to an ancestor module scope that is guaranteed
to be present in a .mod file, but is not guaranteed to be in the PFT. This
difference is accommodated by tying processing directly to a front end scope.
Function scopes that can be processed on the fly are done that way; the
resulting variable information is never stored. Module and submodule scopes
whose symbol information may be needed during lowering of any number of module
procedures are instead cached on first use, and reused as needed.

These changes are a direct extension of current code. All module and submodule
variables in scope are processed, whether referenced or not. A possible
alternative would be to instead process symbols only when first used. While
this could ultimately be beneficial, such an approach must account for the
presence of equivalence groups. That information is not currently available
for on-the-fly variable processing.

Some additional changes are needed to include submodules in places where
modules must be considered, and to include separate module procedures in
places where other subprogram variants are considered. There is also a fix
for a bug involving the use of variables in an equivalence group in a
namelist group, which also involves scope processing code.


https://reviews.llvm.org/D139892

Files:
  flang/include/flang/Lower/ConvertVariable.h
  flang/include/flang/Lower/Mangler.h
  flang/include/flang/Lower/PFTBuilder.h
  flang/lib/Lower/Bridge.cpp
  flang/lib/Lower/ConvertVariable.cpp
  flang/lib/Lower/IO.cpp
  flang/lib/Lower/Mangler.cpp
  flang/lib/Lower/PFTBuilder.cpp
  flang/test/Lower/pre-fir-tree01.f90
  flang/test/Lower/pre-fir-tree02.f90
  flang/test/Lower/pre-fir-tree06.f90
  flang/test/Lower/pre-fir-tree07.f90
  flang/test/Lower/submodule.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139892.482303.patch
Type: text/x-patch
Size: 64155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221213/452b6747/attachment-0001.bin>


More information about the flang-commits mailing list