[flang-commits] [PATCH] D103621: [flang] Generate type info symbols outside of derived type scopes

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Jun 4 05:39:24 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1971960a6fed: [flang] Generate type info symbols outside of derived type scopes (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103621/new/

https://reviews.llvm.org/D103621

Files:
  flang/lib/Semantics/runtime-type-info.cpp
  flang/test/Semantics/typeinfo01.f90


Index: flang/test/Semantics/typeinfo01.f90
===================================================================
--- flang/test/Semantics/typeinfo01.f90
+++ flang/test/Semantics/typeinfo01.f90
@@ -5,10 +5,12 @@
   type :: t1
     integer :: n
   end type
+!CHECK: Module scope: m01
 !CHECK: .c.t1, SAVE, TARGET: ObjectEntity type: TYPE(component) shape: 0_8:0_8 init:[component::component(name=.n.n,genre=1_1,category=0_1,kind=4_1,rank=0_1,offset=0_8,characterlen=value(genre=1_1,value=0_8),derived=NULL(),lenvalue=NULL(),bounds=NULL(),initialization=NULL())]
 !CHECK: .dt.t1, SAVE, TARGET: ObjectEntity type: TYPE(derivedtype) init:derivedtype(binding=NULL(),name=.n.t1,sizeinbytes=4_8,parent=NULL(),uninstantiated=NULL(),kindparameter=NULL(),lenparameterkind=NULL(),component=.c.t1,procptr=NULL(),special=NULL())
-!CHECK: .n.t1, SAVE, TARGET: ObjectEntity type: CHARACTER(2_8,1) init:"t1"
 !CHECK: .n.n, SAVE, TARGET: ObjectEntity type: CHARACTER(1_8,1) init:"n"
+!CHECK: .n.t1, SAVE, TARGET: ObjectEntity type: CHARACTER(2_8,1) init:"t1"
+!CHECK: DerivedType scope: t1
 end module
 
 module m02
@@ -229,10 +231,10 @@
 !CHECK: .lpk.t, SAVE, TARGET: ObjectEntity type: INTEGER(1) shape: 0_8:0_8 init:[INTEGER(1)::8_1]
  contains
   subroutine s1(x)
+!CHECK: .b.t.1.automatic, SAVE, TARGET: ObjectEntity type: TYPE(value) shape: 0_8:1_8,0_8:0_8 init:reshape([value::value(genre=2_1,value=1_8),value(genre=3_1,value=0_8)],shape=[2,1])
 !CHECK: .c.t.1, SAVE, TARGET: ObjectEntity type: TYPE(component) shape: 0_8:3_8 init:[component::component(name=.n.allocatable,genre=3_1,category=1_1,kind=4_1,rank=1_1,offset=0_8,characterlen=value(genre=1_1,value=0_8),derived=NULL(),lenvalue=NULL(),bounds=NULL(),initialization=NULL()),component(name=.n.automatic,genre=4_1,category=1_1,kind=4_1,rank=1_1,offset=96_8,characterlen=value(genre=1_1,value=0_8),derived=NULL(),lenvalue=NULL(),bounds=.b.t.1.automatic,initialization=NULL()),component(name=.n.chauto,genre=4_1,category=3_1,kind=1_1,rank=0_1,offset=72_8,characterlen=value(genre=3_1,value=0_8),derived=NULL(),lenvalue=NULL(),bounds=NULL(),initialization=NULL()),component(name=.n.pointer,genre=2_1,category=1_1,kind=4_1,rank=0_1,offset=48_8,characterlen=value(genre=1_1,value=0_8),derived=NULL(),lenvalue=NULL(),bounds=NULL(),initialization=target)]
 !CHECK: .dt.t.1, SAVE, TARGET: ObjectEntity type: TYPE(derivedtype) init:derivedtype(binding=NULL(),name=.n.t,sizeinbytes=144_8,parent=NULL(),uninstantiated=.dt.t,kindparameter=NULL(),lenparameterkind=.lpk.t.1,component=.c.t.1,procptr=NULL(),special=NULL())
 !CHECK: .lpk.t.1, SAVE, TARGET: ObjectEntity type: INTEGER(1) shape: 0_8:0_8 init:[INTEGER(1)::8_1]
-!CHECK: .b.t.1.automatic, SAVE, TARGET: ObjectEntity type: TYPE(value) shape: 0_8:1_8,0_8:0_8 init:reshape([value::value(genre=2_1,value=1_8),value(genre=3_1,value=0_8)],shape=[2,1])
     type(t(*)), intent(in) :: x
   end subroutine
 end module
Index: flang/lib/Semantics/runtime-type-info.cpp
===================================================================
--- flang/lib/Semantics/runtime-type-info.cpp
+++ flang/lib/Semantics/runtime-type-info.cpp
@@ -54,8 +54,8 @@
   SomeExpr SaveNameAsPointerTarget(Scope &, const std::string &);
   const SymbolVector *GetTypeParameters(const Symbol &);
   evaluate::StructureConstructor DescribeComponent(const Symbol &,
-      const ObjectEntityDetails &, Scope &, const std::string &distinctName,
-      const SymbolVector *parameters);
+      const ObjectEntityDetails &, Scope &, Scope &,
+      const std::string &distinctName, const SymbolVector *parameters);
   evaluate::StructureConstructor DescribeComponent(
       const Symbol &, const ProcEntityDetails &, Scope &);
   evaluate::StructureConstructor PackageIntValue(
@@ -440,12 +440,12 @@
               },
               [&](const ObjectEntityDetails &object) {
                 dataComponents.emplace_back(DescribeComponent(
-                    symbol, object, dtScope, distinctName, parameters));
+                    symbol, object, scope, dtScope, distinctName, parameters));
               },
               [&](const ProcEntityDetails &proc) {
                 if (IsProcedurePointer(symbol)) {
                   procPtrComponents.emplace_back(
-                      DescribeComponent(symbol, proc, dtScope));
+                      DescribeComponent(symbol, proc, scope));
                 }
               },
               [&](const ProcBindingDetails &) { // handled in a later pass
@@ -606,7 +606,8 @@
 
 evaluate::StructureConstructor RuntimeTableBuilder::DescribeComponent(
     const Symbol &symbol, const ObjectEntityDetails &object, Scope &scope,
-    const std::string &distinctName, const SymbolVector *parameters) {
+    Scope &dtScope, const std::string &distinctName,
+    const SymbolVector *parameters) {
   evaluate::StructureConstructorValues values;
   auto &foldingContext{context_.foldingContext()};
   auto typeAndShape{evaluate::characteristics::TypeAndShape::Characterize(
@@ -627,7 +628,8 @@
   AddValue(values, componentSchema_, "offset"s, IntExpr<8>(symbol.offset()));
   // CHARACTER length
   auto len{typeAndShape->LEN()};
-  if (const semantics::DerivedTypeSpec * pdtInstance{scope.derivedTypeSpec()}) {
+  if (const semantics::DerivedTypeSpec *
+      pdtInstance{dtScope.derivedTypeSpec()}) {
     auto restorer{foldingContext.WithPDTInstance(*pdtInstance)};
     len = Fold(foldingContext, std::move(len));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103621.349837.patch
Type: text/x-patch
Size: 5419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20210604/4b7e4559/attachment-0001.bin>


More information about the flang-commits mailing list