This is an archive of the discontinued LLVM Phabricator instance.

[flang][runtime] Add API to help with the difficult array constructor cases
ClosedPublic

Authored by jeanPerier on Feb 20 2023, 9:18 AM.

Details

Summary

This runtime API can be used to lower any flavor of array constructors,
but is mainly intended to be used with:

  • array constructors for which the extent or length parameters cannot be computed without lowering some ac-value or ac-implied-do-control that cannot be pre-evaluated.
  • array constructors of a derived type with allocatable component where copy is not trivial or PDTS.

Example of use cases:

  • [((i+j,i=1, ifoo()), j=1,n)] where ifoo() is not pure.
  • [return_allocatable_array(), return_allocatable_array()]

Diff Detail

Event Timeline

jeanPerier created this revision.Feb 20 2023, 9:18 AM
Herald added a project: Restricted Project. · View Herald Transcript
jeanPerier requested review of this revision.Feb 20 2023, 9:18 AM
PeteSteinfeld accepted this revision.Feb 20 2023, 1:07 PM

All builds and tests correctly and looks good.

flang/include/flang/Runtime/array-constructor.h
54

"it's" should be its ("it's" is a contraction of "it is" while "its" is the possessive pronoun of "it").

This revision is now accepted and ready to land.Feb 20 2023, 1:07 PM

Correct typo in comment caught by Pete.

Add note next to Assign runtime to extend its contract to accept
non conforming array operands as long as they have the same number
of elements. The implementation already supported that, and the
array constructor runtime takes advantage of that to avoid
reshaping "to" when it a multidimensional array is pushed into it.