This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Array constructor lowering [part 3/4]
ClosedPublic

Authored by jeanPerier on Feb 21 2023, 12:38 PM.

Details

Summary

Lower the cases that require runtime support to deal
with the allocation, reallocation, or copy of ac-values to
the array constructor storage.

Depends on D144411, D144512

Diff Detail

Event Timeline

jeanPerier created this revision.Feb 21 2023, 12:38 PM
Herald added a project: Restricted Project. · View Herald Transcript
jeanPerier requested review of this revision.Feb 21 2023, 12:38 PM

All builds and tests correctly. I had some nits and questions. But I'm not sure I understand this well enough to approve. Valentin should take a look.

flang/include/flang/Optimizer/Builder/FIRBuilder.h
341

I didn't see anywhere that this interface was called. Is that OK?

flang/lib/Lower/ConvertArrayConstructor.cpp
300

"know" should be "known".

301

This would make more sense if the ")" appeared after the word "reallocation".

303

What does the "extent" argument represent? Does this constructor only apply to singly dimensioned arrays?

316

This is the only place where the data member declare gets assigned a value in this constructor. Is that OK?

jeanPerier marked 2 inline comments as done.Feb 22 2023, 12:57 AM
jeanPerier added inline comments.
flang/include/flang/Optimizer/Builder/FIRBuilder.h
341

It is called twice in RuntimeTempStrategy constructor (initialBoxValue = builder.createBox(...) around line 319 and 338).

flang/lib/Lower/ConvertArrayConstructor.cpp
303

Yes, array constructors are 1 ranked arrays. Extent is the pre-computed extent of the array constructor, if it was possible to compute it. I'll make it an std::optional so that it is more clear that it may be null here.
I added comment about the arguments.

316

Yes, I added a comment in the else case:

The declare operation cannot be emitted in this case since the final
array constructor has not yet been allocated. Instead, the resulting
temporary variable will be extracted from the allocatable descriptor
after all the API calls.

And made the member an std::optional so that it is clearer that this member may not be always set (mlir::Value and operation always have a sort of "optional" state were they can be left null and if (value) will tell if it was not yet set, but using std::optional better convey the intent).

Correct typos in comments, clarify some comments, and make
some members and argument std::optional instead of relying
on the null mlir::Value state.
Thanks for the review Pete.

This revision is now accepted and ready to land.Feb 23 2023, 11:19 AM
This revision was automatically updated to reflect the committed changes.