This is an archive of the discontinued LLVM Phabricator instance.

[flang] Adapt descriptor codegen to support unlimited polymorphic entities
ClosedPublic

Authored by clementval on Nov 23 2022, 9:20 AM.

Details

Summary

Code generation to create and populate the descriptor (element size and
type code) is based on the boxed result type. This does not work well with
unlimited polymorphic entities since the fir type does not represent what is
actually emboxed or reboxed.
In the case of emboxing, the input type will be used to populate
the descriptor element size and type code.
When reboxing an unlimited polymorphic to a unlimited polymorphic entities, the
element size and type code is retrieve from the input box.

Diff Detail

Event Timeline

clementval created this revision.Nov 23 2022, 9:20 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 23 2022, 9:20 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Nov 23 2022, 9:20 AM
clementval retitled this revision from [flang] Adapt descript codegen to support unlimited polymoprhic entities to [flang] Adapt descriptor codegen to support unlimited polymorphic entities.Nov 23 2022, 9:27 AM

All builds and tests correctly, and aside from a few nits, looks good to me. But I don't understand the code very well. @jeanPerier should take a look.

flang/lib/Frontend/CompilerInvocation.cpp
954 ↗(On Diff #477531)

Are we ready for this change?

flang/lib/Optimizer/CodeGen/CodeGen.cpp
1559

I assume that this should read "type has no type ..."

1583

Should read "entity" rather than "entities".

ddress Pete's comments

clementval marked 3 inline comments as done.Nov 23 2022, 11:18 AM
clementval added inline comments.
flang/lib/Frontend/CompilerInvocation.cpp
954 ↗(On Diff #477531)

No. Leftover from my tests. When we are ready the option will be removed completely.

clementval planned changes to this revision.Nov 24 2022, 12:32 AM
clementval marked an inline comment as done.

Some more changes need to be done when handling the type descriptor.

Update type descriptor handling

jeanPerier accepted this revision.Nov 24 2022, 1:32 AM

Looks great to me

flang/lib/Optimizer/CodeGen/CodeGen.cpp
1960

Is loweredBox an mlir::Value here ? If so, I am a bit puzzled with the implicit conversion to mlir::Type. I would add a getType() just to make what is passed here clearer.

This revision is now accepted and ready to land.Nov 24 2022, 1:32 AM
clementval marked an inline comment as done.Nov 24 2022, 1:47 AM
clementval added inline comments.
flang/lib/Optimizer/CodeGen/CodeGen.cpp
1960

Yes. There are now two functions for consDescriptorPrefix. One for XReboxOp and one for EmboxOp and XEmboxOp. The one for XReboxOp takes the loweredBox mlir::Value in so we can query the input descriptor.

This revision was automatically updated to reflect the committed changes.
clementval marked an inline comment as done.