This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lowers calls to procedure with CONTIGUOUS assumed shape dummies
ClosedPublic

Authored by jeanPerier on Sep 23 2022, 8:19 AM.

Details

Summary

Copy-in/copy-out was not triggered when calling a procedure with a
CONTIGUOUS assumed shape. The actual argument must be copied-in/out
if it is not contiguous.
The copy-in/copy-out takes care of argument optionality, and uses a
runtime check in order to only do the copy if the actual is not
contiguous at runtime.

This was already implemented for explicit shape dummy arguments. This
patch takes advantage of this implementation to deal with the copy-in
copy-out aspects. It only need add code to deals with wrapping the
created bare contiguous address into a fir.box (runtime descriptor),
taking care of the optional box aspects.

Using this existing code is only possible for actual argument that can
be passed via a bare address. Add a TODO for polymorphic entity, PDTs
and assumed rank where the existing copy-in/copy-out code may fail
(these copies are more complex) and that cannot be tested currently.

Diff Detail

Event Timeline

jeanPerier created this revision.Sep 23 2022, 8:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2022, 8:19 AM
jeanPerier requested review of this revision.Sep 23 2022, 8:19 AM

All builds and tests correctly and looks good, except for the two nits I mentioned. But I don't understand this code very well. @clementval should take a look and provide feedback.

flang/lib/Lower/ConvertExpr.cpp
3074–3078

Did you mean to say "return an"?

3308

"polymorphic"

clementval accepted this revision.Sep 26 2022, 12:35 AM

LGTM

flang/lib/Lower/ConvertExpr.cpp
3075
This revision is now accepted and ready to land.Sep 26 2022, 12:35 AM
jeanPerier marked 3 inline comments as done.

Correct typos in comments.