This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Lower structure constructor via AssignOp.
ClosedPublic

Authored by vzakhari on May 30 2023, 2:14 PM.

Details

Summary

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.

Diff Detail

Event Timeline

vzakhari created this revision.May 30 2023, 2:14 PM
vzakhari requested review of this revision.May 30 2023, 2:14 PM
tblah accepted this revision.May 31 2023, 3:09 AM

Looks good to me! Thanks for this

flang/lib/Lower/ConvertExprToHLFIR.cpp
1636–1647

+1

This revision is now accepted and ready to land.May 31 2023, 3:09 AM
This revision was automatically updated to reflect the committed changes.