[PATCH] D102768: [flang] simplify derived type info table format
Jean Perier via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 19 06:25:34 PDT 2021
jeanPerier created this revision.
jeanPerier added reviewers: klausler, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
jeanPerier requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
- Replace class(*) member by a c_ptr member to avoid having to handle polymorphic components in the type info table generation. Polymorphic entity handling will require these very tables to be lowered properly. Note: keep the init as NullPointer/Designators. This is technically invalid Fortran, the init should have c_ptr type. But wrapping this in a C_LOC intrinsic call would make runtime generation and lowering more complex with no real benefits.
- ComponentIterator is crashing when used on the generated derived types in GetScope. This patch makes GetScope more robust, but it is not entirely clear to me why this is only happening with the generated derived types.
- The type of generated character globals was incorrect because Scope::FindType was matching character types with different length. Add a CharacterTypeSpec == operator to fix this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102768
Files:
flang/include/flang/Semantics/tools.h
flang/include/flang/Semantics/type.h
flang/module/__fortran_type_info.f90
flang/test/Semantics/typeinfo01.f90
Index: flang/test/Semantics/typeinfo01.f90
===================================================================
--- flang/test/Semantics/typeinfo01.f90
+++ flang/test/Semantics/typeinfo01.f90
@@ -236,3 +236,14 @@
type(t(*)), intent(in) :: x
end subroutine
end module
+
+module m12
+ type :: t1
+ integer :: n
+ integer :: n2
+ integer :: n_3
+ ! CHECK: .n.n, SAVE, TARGET: ObjectEntity type: CHARACTER(1_8,1) init:"n"
+ ! CHECK: .n.n2, SAVE, TARGET: ObjectEntity type: CHARACTER(2_8,1) init:"n2"
+ ! CHECK: .n.n_3, SAVE, TARGET: ObjectEntity type: CHARACTER(3_8,1) init:"n_3"
+ end type
+end module
Index: flang/module/__fortran_type_info.f90
===================================================================
--- flang/module/__fortran_type_info.f90
+++ flang/module/__fortran_type_info.f90
@@ -88,7 +88,7 @@
type(DerivedType), pointer :: derived ! for category == Derived
type(Value), pointer :: lenValue(:) ! (SIZE(derived%lenParameterKind))
type(Value), pointer :: bounds(:, :) ! (2, rank): lower, upper
- class(*), pointer :: initialization
+ type(__builtin_c_ptr) :: initialization
end type
type :: ProcPtrComponent ! procedure pointer components
Index: flang/include/flang/Semantics/type.h
===================================================================
--- flang/include/flang/Semantics/type.h
+++ flang/include/flang/Semantics/type.h
@@ -154,6 +154,9 @@
: IntrinsicTypeSpec(TypeCategory::Character, std::move(kind)),
length_{std::move(length)} {}
const ParamValue &length() const { return length_; }
+ bool operator==(const CharacterTypeSpec &that) const {
+ return kind() == that.kind() && length_ == that.length_;
+ }
std::string AsFortran() const;
private:
Index: flang/include/flang/Semantics/tools.h
===================================================================
--- flang/include/flang/Semantics/tools.h
+++ flang/include/flang/Semantics/tools.h
@@ -459,7 +459,10 @@
name_iterator &nameIterator() { return nameIterator_; }
name_iterator nameEnd() { return nameEnd_; }
const Symbol &GetTypeSymbol() const { return derived_->typeSymbol(); }
- const Scope &GetScope() const { return DEREF(derived_->scope()); }
+ const Scope &GetScope() const {
+ return DEREF(
+ derived_->scope() ? derived_->scope() : GetTypeSymbol().scope());
+ }
bool operator==(const ComponentPathNode &that) const {
return &*derived_ == &*that.derived_ &&
nameIterator_ == that.nameIterator_ &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102768.346431.patch
Type: text/x-patch
Size: 2559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210519/8fb65fcc/attachment.bin>
More information about the llvm-commits
mailing list