[flang-commits] [flang] [flang][runtime] Establish derived type desc properly. (PR #67623)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Wed Sep 27 17:29:52 PDT 2023


================
@@ -96,12 +96,19 @@ void Descriptor::Establish(const typeInfo::DerivedType &dt, void *p, int rank,
 
 OwningPtr<Descriptor> Descriptor::Create(TypeCode t, std::size_t elementBytes,
     void *p, int rank, const SubscriptValue *extent,
-    ISO::CFI_attribute_t attribute, int derivedTypeLenParameters) {
-  std::size_t bytes{SizeInBytes(rank, true, derivedTypeLenParameters)};
+    ISO::CFI_attribute_t attribute, bool addendum,
+    const typeInfo::DerivedType *dt) {
   Terminator terminator{__FILE__, __LINE__};
+  RUNTIME_CHECK(terminator, t.IsDerived() == (dt != nullptr));
+  int derivedTypeLenParameters = dt ? dt->LenParameters() : 0;
+  std::size_t bytes{SizeInBytes(rank, addendum, derivedTypeLenParameters)};
   Descriptor *result{
       reinterpret_cast<Descriptor *>(AllocateMemoryOrCrash(terminator, bytes))};
-  result->Establish(t, elementBytes, p, rank, extent, attribute, true);
----------------
vzakhari wrote:

Note that I removed the unconditional addendum creation.  I am not sure it is a good idea, since @jeanPerier mentioned that the compiler generated code may access addendum unconditionally in some cases, but the testing is clean for the change.  Jean, please let me know about the cases that might be broken because of this.

https://github.com/llvm/llvm-project/pull/67623


More information about the flang-commits mailing list