This is an archive of the discontinued LLVM Phabricator instance.

[flang] Delegate pointer association to class(*) pointer to the runtime
ClosedPublic

Authored by clementval on Nov 30 2022, 8:08 AM.

Details

Summary

Pointer association with an unlimited polymorphic pointer on the lhs
requires more than just updating the base_addr. Delegate the association to
the runtime function PointerAssociation.

Diff Detail

Event Timeline

clementval created this revision.Nov 30 2022, 8:08 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 30 2022, 8:08 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Nov 30 2022, 8:08 AM
PeteSteinfeld accepted this revision.Nov 30 2022, 8:41 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Nov 30 2022, 8:41 AM
jeanPerier added inline comments.Nov 30 2022, 10:09 AM
flang/lib/Lower/Bridge.cpp
2721

Does the right hand side always have to be an allocatable/pointer if the left hand side is unlimited polymorphic ? If so, I think it would be worth adding a standard reference here.

flang/test/Lower/polymorphic.f90
145

Sorry, I misunderstood your question earlier. I do not think it is OK to allow convertion from fir.ref<fir.box<>> to fir.box<none>. It is cheating the SSA value model of fir.box. Any following code would thing the convert results is immutable while it is not since the convert operand can be modified.

So I think you have to load and then cast to a fir.box<None> here. I know that will imply making a copy of the descriptor, which is useless here, but we should fix that in a more generic way by skipping the copy in the fir.load codegen if we know we can.

clementval added inline comments.Nov 30 2022, 12:05 PM
flang/test/Lower/polymorphic.f90
145

Makes sense. I'll update the code to include the load if necessary.