[flang] Do not convey captured globals through host link
authorJean Perier <jperier@nvidia.com>
Tue, 20 Dec 2022 12:49:38 +0000 (13:49 +0100)
committerJean Perier <jperier@nvidia.com>
Tue, 20 Dec 2022 12:52:53 +0000 (13:52 +0100)
commit93129ca8d1cf618390a16e5d4315d0fd15170c51
tree86c75911ae7d7ad20649d180e929713985cbe7ff
parent16c4c4e04c146b1d1bb9ba813371f23603f1bf8c
[flang] Do not convey captured globals through host link

Addresses and properties (bounds, length parameters) of host
variables associated in an internal procedure were all passed via
an extra tuple argument of the internal procedure.
This extra tuple is in general an overhead: it must be created and
passed, and require creating thunks when taking the address of the
internal procedure.
This patch allows not using the tuple for host global variables
(from modules, common block, or local saved variables) since they can
be instantiated from the fir.global symbol in the internal procedure
instead.
Add a fir.internal_proc attribute to mlir::FuncOp for internal procedures
so that ArrayValueCopy can still detect internal procedures even if they
do not have a tuple argument.

Differential Revision: https://reviews.llvm.org/D140288
14 files changed:
flang/include/flang/Lower/CallInterface.h
flang/include/flang/Lower/HostAssociations.h
flang/include/flang/Lower/PFTBuilder.h
flang/include/flang/Optimizer/Dialect/FIROpsSupport.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
flang/lib/Lower/HostAssociations.cpp
flang/lib/Lower/PFTBuilder.cpp
flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
flang/test/Lower/explicit-interface-results-2.f90
flang/test/Lower/host-associated-functions.f90
flang/test/Lower/host-associated-globals.f90 [new file with mode: 0644]
flang/test/Lower/host-associated.f90
flang/test/Lower/polymorphic.f90