This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] user defined assignment codegen
ClosedPublic

Authored by jeanPerier on Jun 22 2023, 3:16 AM.

Details

Summary

Add codegen support for hlfir.region_assign with user defined
assignment.

It is currently a bit pessimistic, because outside of forall, it
does not use the PURE aspect, if any, of the assignment routine to
rule out that the routine can write to something else than the LHS that
could overlap with the RHS.
However, the current lowering is anyway adding parenthesis around the
RHS, so this should not cause performance regressions.

Depends on D153404

Diff Detail

Event Timeline

jeanPerier created this revision.Jun 22 2023, 3:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 3:16 AM
jeanPerier requested review of this revision.Jun 22 2023, 3:16 AM
tblah added inline comments.Jun 23 2023, 2:42 AM
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
382

How do we know that T doesn't need conversion?

jeanPerier added inline comments.Jun 23 2023, 6:30 AM
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
382

We do not, thanks for catching this, I added convert here.

Add a convert to cover the case where the scalar value type mismatch
the one in the variable.

tblah added inline comments.Jun 23 2023, 7:43 AM
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
389

Thanks for fixing. I think this needs a convert as well

jeanPerier added inline comments.Jun 26 2023, 2:19 AM
flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp
389

This one is more tricky. So far there is no conversion at the hlfir.expr level, and I think trying to modify the input would increase the risk of bug more than anything. I do not expect that the T can mismatch here, although there is indeed nothing that reliably prevents it. So for now, I added a TODO in case there is mismatch.

Add a TODO to cover the unlikely case of type mismatch with the
hlfir.expr.

tblah accepted this revision.Jun 26 2023, 2:25 AM

Thanks Jean. LGTM

This revision is now accepted and ready to land.Jun 26 2023, 2:25 AM
This revision was automatically updated to reflect the committed changes.