This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Codegen of hlfir.region_assign where LHS conflicts
ClosedPublic

Authored by jeanPerier on Jun 29 2023, 2:32 AM.

Details

Summary

When the analysis of hlfir.region_assign determined that the LHS region
evaluation may be impacted by the assignment effects, all LHS must be
fully evaluated and saved before any assignment is done.

This patch adds TemporaryStorage variants to save address, including
vector subscripted entities addresses whose shape must be saved.
It uses the DescriptorStack runtime to deal with complex cases inside
forall. For the sake of simplicity, this is also used for vector
subscripted LHS outside of foralls (each element address is saved as
a descriptor on this stack. This is a bit suboptimal, but it is a safe
start that will work with all kinds of type (polymorphic, PDTs...)
without further work). Another approach would be to saved only the
values that are conflicting in the LHS computation, but this would
require a much more complex analysis of the LHS region DAG.

Depends on D154033

Diff Detail

Event Timeline

jeanPerier created this revision.Jun 29 2023, 2:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 2:32 AM
jeanPerier requested review of this revision.Jun 29 2023, 2:32 AM
tblah accepted this revision.Jun 29 2023, 4:07 AM

Looks great to me. It is good to see the plan coming together :)

This revision is now accepted and ready to land.Jun 29 2023, 4:07 AM
vzakhari accepted this revision.Jun 29 2023, 3:19 PM

Thank you, Jean!

flang/include/flang/Optimizer/Builder/TemporaryStorage.h
179

nit

flang/lib/Optimizer/Builder/TemporaryStorage.cpp
283

nit

flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
709

nit

710

nit

jeanPerier marked 4 inline comments as done.Jun 29 2023, 11:55 PM

Thanks for the reviews! Nits addressed in merge commit.