This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix fir.dispatch_table generation with derived-type parameter with kind type parameter
ClosedPublic

Authored by clementval on Dec 16 2022, 5:16 AM.

Details

Summary

When generating the fir.dispatch_table operation, the name of the parent
derived-type needs to be mangled. For this the type instantiation
DerivedTypeSpec needs to be retrieved to have the correct kind type parameters.

Diff Detail

Event Timeline

clementval created this revision.Dec 16 2022, 5:16 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 16 2022, 5:16 AM
clementval requested review of this revision.Dec 16 2022, 5:16 AM

@klausler Is it ok to modify FindParentComponent like this or is there a better way to retrieve the parent type instantiation DerivedTypeSpec from a DerivedTypeSpec?

clementval edited the summary of this revision. (Show Details)Dec 16 2022, 5:18 AM
jeanPerier added inline comments.Dec 16 2022, 6:50 AM
flang/lib/Evaluate/type.cpp
213–214

Looking at the comment same as typeSymbol_.scope() unless PDT here: https://github.com/llvm/llvm-project/blob/main/flang/include/flang/Semantics/type.h#L310, I think using derived.scope() should be enough, but I did not check that this comment was honored.

klausler added inline comments.Dec 16 2022, 7:19 AM
flang/lib/Evaluate/type.cpp
213–214

If "derived" is not a PDT instantiation the two scopes should be the same. If it is a PDT instantiation, "derived" will have its own scope for all of the object and pointer components, including the parent; generics and bindings are still found in the original scope.

In any case, yes, "derived.scope()" should not be null outside error recovery situations.

Please always use braces around "if" statement bodies here, thanks.

PeteSteinfeld accepted this revision.Dec 16 2022, 7:58 AM

Aside from Peter's comment on adding braces, all builds and tests correctly and looks good.

This revision is now accepted and ready to land.Dec 16 2022, 7:58 AM

clang-format + if braces