[all-commits] [llvm/llvm-project] f88a94: [flang] Generate PDT runtime type info in the type...

jeanPerier via All-commits all-commits at lists.llvm.org
Thu Mar 3 01:16:15 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f88a9497a2bd731e0e8a6f913954007c9c7b5479
      https://github.com/llvm/llvm-project/commit/f88a9497a2bd731e0e8a6f913954007c9c7b5479
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2022-03-03 (Thu, 03 Mar 2022)

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

  Log Message:
  -----------
  [flang] Generate PDT runtime type info in the type definition scope

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.

Differential Revision: https://reviews.llvm.org/D120801




More information about the All-commits mailing list