This is an archive of the discontinued LLVM Phabricator instance.

[flang] Do not convey captured globals through host link
ClosedPublic

Authored by jeanPerier on Dec 19 2022, 3:06 AM.

Details

Summary

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.

Diff Detail

Event Timeline

jeanPerier created this revision.Dec 19 2022, 3:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
jeanPerier requested review of this revision.Dec 19 2022, 3:06 AM
PeteSteinfeld accepted this revision.Dec 19 2022, 7:31 AM

Aside from the name of hasTupleAssociations(), all builds and tests correctly and looks good.

flang/include/flang/Lower/HostAssociations.h
35–37

This doesn't seem right. hasTupleAssociations() returns true when there are no tuple symbols? Should this be called hasNoTupleAssociations()?

This revision is now accepted and ready to land.Dec 19 2022, 7:31 AM
jeanPerier added inline comments.Dec 20 2022, 12:19 AM
flang/include/flang/Lower/HostAssociations.h
35–37

Woops, of course, thanks ! I will actually keep the name and reverse the logic since its only use is negating it (so that I can remove the negation).

Honor hasTupleAssociations name by reversing the logic inside and at its use point.

Update one piece of code in ArrayCopyValue that relied on the presence of a tuple
argument to detect internal procedures. Add an fir.internal_proc attribute to internal
function that are capturing host variables so that they can be easily detected even if
they do not have a tuple argument (I thought about using the mangling, but thought
an attribute would be stronger).