[flang][hlfir] Lower structure constructor via AssignOp.
authorSlava Zakharin <szakharin@nvidia.com>
Wed, 31 May 2023 16:06:51 +0000 (09:06 -0700)
committerSlava Zakharin <szakharin@nvidia.com>
Wed, 31 May 2023 18:30:55 +0000 (11:30 -0700)
commit1ca458f78e26e785b6eca2946a7558d8c39c7490
treeb72d7679db9556c992e64e83e85280316cd841f3
parent6facfe10258b475713440953ef46fca6734c0e5e
[flang][hlfir] Lower structure constructor via AssignOp.

I tried this patch, first. Some tests failed because of the extra
finalizations for the temporary LHSs: when LHS component is a derived
type with final subprograms, the finalizations might be detected
by counting/printing in the final subprograms and treated as errors
in the tests, because they are not expected.
So I also tried to reuse the StructureConstructor code lowering to FIR
followed by AsExprOp to produce the HLFIR "value". Unfortunately,
this did not resolve the finalization issues, because AsExprOp may
end up being bufferized into AssignOp as well.
So the extra finalizations are inherent problem for AssignOp,
and it has to be resolved separately. Thus, I decided to proceed
with a "cleaner" direct lowering to HLFIR (the initial patch).

I am thinking about adding an extra flag for AssignOp that would
indicate that the LHS is a compiler generated temporary, so we could
use something like AssignTemporary() in HLFIR-to-FIR converter.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D151752
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/test/Lower/HLFIR/structure-constructor.f90 [new file with mode: 0644]