When AssignOp is used with LHS that is a compiler generated temporary
special care must be taken to initialize the temporary and avoid
finalizations of its components. This change-set adds optional
temporary_lhs attribute for AssignOp to convey this information
to HLFIR-to-FIR conversion pass. Currently, this results in
calling AssignTemporary runtime for doing the assignment.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
LGTM aside from one nit
flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp | ||
---|---|---|
129 | nit: this could have one less level of if nesting (feel free not to change if you don't think this is worth the effort) } else if (assignOp.isTemporaryLHS()) fir::runtime::genAssignTemporary(builder, loc, to, from); else if (lhs.isPolymorphic()) fir::runtime::genAssignPolymorphic(builder, loc, to, from); else fir::runtime::genAssign(builder, loc, to, from); |
Comment Actions
Thanks Slava, this looks like the right solution to me and this will allow using hlfir.assign for derived type array constructor too (and a few other places where we just want "dumb" copies)!
flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp | ||
---|---|---|
129 | +1 |
nit: this could have one less level of if nesting (feel free not to change if you don't think this is worth the effort)