This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Lower post f77 user calls
ClosedPublic

Authored by jeanPerier on Jan 27 2023, 1:24 AM.

Details

Summary

In lowering to HLFIR, deal with user calls involving a mix of:

  • dummy with VALUE
  • Polymorphism
  • contiguous dummy
  • assumed shape dummy
  • OPTIONAL arguments
  • NULL() passed to OPTIONAL arguments.
  • elemental calls

Does not deal with assumed ranked dummy arguments.

This patch unifies the preparation of all arguments that must be passed
in memory and are not passed as allocatable/pointers.

For optionals, the same argument preparation is done, except the utility
that generates the IR for the argument preparation is called inside a
fir.if.

The addressing of array arguments in elemental calls is delayed so that
it can also happen during this argument preparation, and be placed in
the fir.if when the array may be absent.

Structure helpers are added to convey a prepared dummy argument and the
data that may be needed to do the clean-up after the call (temporary
storage deallocation or copy-out). And a utility is added to wrap
the preparation code inside a fir.if and convey these values through
the fir.if.

Certain aspects of this patch brings the HLFIR lowering support beyond
what the current lowering to FIR supports (e.g. handling of NULL(), handling
of optional in elemental calls, handling of copy-in/copy-out involving
polymorphic entities).

Diff Detail

Event Timeline

jeanPerier created this revision.Jan 27 2023, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 1:24 AM
jeanPerier requested review of this revision.Jan 27 2023, 1:24 AM
clementval accepted this revision.Jan 27 2023, 5:10 AM

Looks great. Couple of typos.

flang/lib/Lower/ConvertCall.cpp
639
659

Maybe?

771
772
This revision is now accepted and ready to land.Jan 27 2023, 5:10 AM
jeanPerier marked 4 inline comments as done.

Fix typos (thanks for the review) and rebase.

PeteSteinfeld accepted this revision.Jan 27 2023, 6:18 AM

Aside from the nits on the comments, all builds and tests correctly and looks good.

flang/lib/Lower/ConvertCall.cpp
658

"conditionnaly" should be "conditionally"

663

Should this be "%conditionallyPrepared"?

719

Should read "%conditionallyPrepared".

856

Should read "descriptors may not ..."

1178

I think that this should say "array operands".

jeanPerier marked 5 inline comments as done.

Fix more typos in comments caught by Pete and rebase.

This revision was automatically updated to reflect the committed changes.