This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add runtime default initialization for polymorphic intent(out) dummy
ClosedPublic

Authored by clementval on Jan 9 2023, 5:53 AM.

Details

Summary

This patch adds runtime default initialization for polymorphic
dummy argument. The dynamic type might require default initialization
but not the declared type.

Diff Detail

Event Timeline

clementval created this revision.Jan 9 2023, 5:53 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 9 2023, 5:53 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Jan 9 2023, 5:53 AM
clementval updated this revision to Diff 487405.Jan 9 2023, 6:16 AM

Do it for polymorphic dummy as the dynamic type might
require default initialization but not the declared type

clementval retitled this revision from [flang] Add runtime default initialization for unlimited polymorphic intent(out) dummy to [flang] Add runtime default initialization for polymorphic intent(out) dummy.Jan 9 2023, 6:17 AM
clementval edited the summary of this revision. (Show Details)
PeteSteinfeld accepted this revision.Jan 9 2023, 7:06 AM

Aside from the question on the comment, all builds and tests correctly and looks good.

flang/lib/Lower/ConvertVariable.cpp
628

Shouldn't this comment say "needs" rather than "might need"?

This revision is now accepted and ready to land.Jan 9 2023, 7:06 AM
jeanPerier accepted this revision.Jan 9 2023, 7:29 AM
jeanPerier added inline comments.
flang/lib/Lower/ConvertVariable.cpp
628

I think "might need" is more accurate in the sense that the storage may not need default initialization: it only needs it if the dynamic type requires it. However, we do not know the dynamic type at compile time, so we must call the runtime, but the runtime may not do anything if the dynamic type turns out to not have a default initial value.

clementval added inline comments.Jan 9 2023, 7:55 AM
flang/lib/Lower/ConvertVariable.cpp
628

Jean is correct here. We are not sure it need default initialization but since it might we delegate it to the runtime.