[flang-commits] [PATCH] D120801: [flang] Generate PDT runtime type info in the type definition scope

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Mar 2 01:29:05 PST 2022


jeanPerier created this revision.
jeanPerier added a reviewer: klausler.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patches modifies PDT runtime type info generation so that it is
easier to handle derived type descriptor in lowering. It changes three
aspects:

1. The symbol name suffix of runtime type info for PDT instantiation is changed from a serial number unrelated to the types to an encoding of the instantiated KIND parameters.
2. New runtime type info is not created for each instantiation of PDT without KIND parameters (only length parameters). Instead, the runtime type info of the type definition is always used. It is updated to contain the component descriptions.
3. Runtime type info of PDT instantiation is now always generated in the scope where the type is defined. If several PDT type instantiation are made in different scope with the same kind parameters, they will use the same runtime type info.

Rational of the change:

In lowering, derived type descriptors are not mapped when instantiating derived
type objects. They are mapped later when symbol knowledge is not available anymore.
This mapping is based on the FIR representation of derived types. For
PDT, the FIR type information does not allow deducing the instantiation
scope, it only allows retrieving the type name, the type _definition_
scope, and the kind parameter values. Therefore, in order to be able to
retrieve the derived type descriptor from a FIR type, the derived type
descriptor must be generated in the definition scope and must reflect
the kind parameters. This justifies the need for changes 1. and 3.
above (suffix and scope change). Changes 2. comes from the fact that
all runtime type info of type without kind parameters can be generated
from the type definition, and that because of the suffix change, the
symbol name for type definition and type instantiation are the same.

Although this change is first motivated by how lowering handles derived
types, I believe it is also an improvement from a functional point of
view since this change will allow reducing the number of generated
runtime type info for PDTs, since redundant information (different
instantiations with same kind parameters) will only be generated once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120801

Files:
  flang/include/flang/Semantics/scope.h
  flang/lib/Semantics/compute-offsets.cpp
  flang/lib/Semantics/runtime-type-info.cpp
  flang/lib/Semantics/scope.cpp
  flang/test/Semantics/typeinfo01.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120801.412352.patch
Type: text/x-patch
Size: 14776 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220302/bb6943c1/attachment-0001.bin>


More information about the flang-commits mailing list