This is an archive of the discontinued LLVM Phabricator instance.

[flang] split character procedure arguments in target-rewrite pass
ClosedPublic

Authored by jeanPerier on Jan 25 2022, 12:42 AM.

Details

Summary

When passing a character procedure as a dummy procedure, the result
length must be passed along the function address. This is to cover
the cases where the dummy procedure is declared with assumed length
inside the scope that will call it (it will need the length to allocate
the result on the caller side).

To be compatible with other Fortran compiler, this length must be
appended after all other argument just like character objects
(fir.boxchar).

A fir.boxchar cannot be used to implement this feature because it
is meant to take an object address, not a function address.

Instead, argument like tuple<function type, integer type> {fir.char_proc}
will be recognized as being character dummy procedure in FIR. That way
lowering does not have to do the argument split.

This patch adds tools in Character.h to create this type and tuple
values as well as to recognize them and extract its tuple members.

It also updates the target rewrite pass to split these arguments like
fir.boxchar.

This part is part of fir-dev upstreaming. It was reviwed previously
in: https://github.com/flang-compiler/f18-llvm-project/pull/1393

Diff Detail

Event Timeline

jeanPerier created this revision.Jan 25 2022, 12:42 AM
jeanPerier requested review of this revision.Jan 25 2022, 12:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2022, 12:43 AM
schweitz accepted this revision.Jan 25 2022, 1:06 PM
This revision is now accepted and ready to land.Jan 25 2022, 1:06 PM