This is an archive of the discontinued LLVM Phabricator instance.

[flang] Submodules
ClosedPublic

Authored by vdonaldson on Dec 12 2022, 4:14 PM.

Details

Summary

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.

Diff Detail

Event Timeline

vdonaldson created this revision.Dec 12 2022, 4:14 PM
Herald added a project: Restricted Project. · View Herald Transcript
vdonaldson requested review of this revision.Dec 12 2022, 4:14 PM
PeteSteinfeld accepted this revision.Dec 12 2022, 7:15 PM

Aside from the one formatting nit, all builds and tests correctly and looks good.

flang/lib/Lower/PFTBuilder.cpp
1352

I'm getting a diff on this link when I run clang-format.

This revision is now accepted and ready to land.Dec 12 2022, 7:15 PM
vdonaldson added inline comments.
flang/lib/Lower/PFTBuilder.cpp
1352

Should now be fixed, thanks

Build bots are flagging the code at PFTBuilder.cpp line 1788. I'm looking at the problem.

Build bots are flagging the code at PFTBuilder.cpp line 1788. I'm looking at the problem.

https://reviews.llvm.org/D139975