This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lower allocation with MOLD
ClosedPublic

Authored by clementval on Jan 16 2023, 6:09 AM.

Details

Summary

Lower allocate statement with MOLD= to calls to the Fortran
runtime. PointerApplyMold and AllocatableApplyMold are called
depending on the object to be allocated.

Diff Detail

Event Timeline

clementval created this revision.Jan 16 2023, 6:09 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 16 2023, 6:09 AM
clementval requested review of this revision.Jan 16 2023, 6:09 AM

Apart from the error condition case handling, looks good to me.

flang/lib/Lower/Allocatable.cpp
224

I do not get why this is returning a value, it seems AllocatableApplyMold returns void [1].

https://github.com/llvm/llvm-project/blob/01e8e50ce397dcb08e7dfadab93a53ae31174c67/flang/include/flang/Runtime/allocatable.h#L49

579

I think AllocatableApplyMold will set the status to unallocated regardless of the previous allocation. We should somehow preserve this info so that the program can crash/recover as needed if the allocatable is not deallocated to start with (9.7.1.3 point 1, first bullet point).

Maybe AllocatableApplyMold should actually be the one doing this check like with some other entry points.

Return from AllocatableApplyMold if the descriptor is
allocated so the error can be caught by AllocatableAllocate
to respect the first bullet of 9.7.1.3 point 1.

jeanPerier accepted this revision.Jan 17 2023, 2:38 AM

clang-format issue in flang/lib/Lower/Allocatable.cpp somewhere, looks great otherwise.

This revision is now accepted and ready to land.Jan 17 2023, 2:38 AM

clang-format

PeteSteinfeld accepted this revision.Jan 17 2023, 6:42 AM

I saw one clang-format diff. Otherwise, all builds and tests correctly and looks good.

flang/lib/Lower/Allocatable.cpp
216–217

I get a clang-format diff here.

This revision was automatically updated to reflect the committed changes.