This is an archive of the discontinued LLVM Phabricator instance.

[flang] Allocate polymorphic with SOURCE= using ApplyMold
ClosedPublic

Authored by clementval on Jan 18 2023, 12:34 AM.

Details

Summary

Source allocation is similar to mold allocation + assignment. Use
ApplyMold runtime entry point for polymorphic source allocation.
It could be generalized for other source allocation.

Diff Detail

Event Timeline

clementval created this revision.Jan 18 2023, 12:34 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 18 2023, 12:34 AM
clementval requested review of this revision.Jan 18 2023, 12:34 AM
clementval planned changes to this revision.Jan 18 2023, 12:43 AM

This is not working as expected. An custom runtime entry point will be added.

Use custom entry point

clementval edited the summary of this revision. (Show Details)Jan 18 2023, 1:36 AM
clementval added a reviewer: klausler.

Fix function name length

PeteSteinfeld edited the summary of this revision. (Show Details)Jan 18 2023, 5:52 AM
jeanPerier accepted this revision.Jan 18 2023, 5:56 AM

LGTM, out of curiosity what went wrong when using the MOLD runtime entry point (I would also have expected the MOLD and SOURCE case to be similar expect for the extra assignment part in SOURCE)?

This revision is now accepted and ready to land.Jan 18 2023, 5:56 AM
PeteSteinfeld accepted this revision.Jan 18 2023, 6:05 AM

All builds and tests correctly and looks good.

But it would be even better if you would add a test to .../llvm-project/flang/unittests/Runtime.

LGTM, out of curiosity what went wrong when using the MOLD runtime entry point (I would also have expected the MOLD and SOURCE case to be similar expect for the extra assignment part in SOURCE)?

In fact ApplyMold seems to do the trick just fine and would be needed as well for TypeCategory::Character. I'll will update the patch to use ApplyMold so the runtime has less entry point.

  • Switch to ApplyMold for polymorphic source allocation
  • Add unittest
clementval requested review of this revision.Jan 18 2023, 7:41 AM
clementval retitled this revision from [flang] Allocate unlimited polymorphic with unlimited polymorphic source to [flang] Allocate polymorphic with SOURCE= using ApplyMold .
clementval edited the summary of this revision. (Show Details)

@jeanPerier @PeteSteinfeld Since the new update is quite different, can you have a second look?

PeteSteinfeld accepted this revision.Jan 18 2023, 9:43 AM

Thanks, @clementval. All still looks good.

This revision is now accepted and ready to land.Jan 18 2023, 9:43 AM

@jeanPerier @PeteSteinfeld Since the new update is quite different, can you have a second look?

Looks good, thanks for this simplification!