[flang-commits] [flang] 9c3550f - [flang][runtime] Use Descriptor::Establish() in elemental derived type defined assignment calls
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Mar 10 10:30:44 PST 2023
Author: Peter Klausler
Date: 2023-03-10T10:26:22-08:00
New Revision: 9c3550f69a0d08229996fa37ae6880e6248b712b
URL: https://github.com/llvm/llvm-project/commit/9c3550f69a0d08229996fa37ae6880e6248b712b
DIFF: https://github.com/llvm/llvm-project/commit/9c3550f69a0d08229996fa37ae6880e6248b712b.diff
LOG: [flang][runtime] Use Descriptor::Establish() in elemental derived type defined assignment calls
The code in DoElementalDefinedAssignment() needs to establish its
to & from per-element descriptors with Establish() rather than
copying an array's descriptor and then setting its rank to zero;
the current technique loses the information in the addendum.
Differential Revision: https://reviews.llvm.org/D145753
Added:
Modified:
flang/runtime/assign.cpp
Removed:
################################################################################
diff --git a/flang/runtime/assign.cpp b/flang/runtime/assign.cpp
index b737e47f6d37..b4d9061846e9 100644
--- a/flang/runtime/assign.cpp
+++ b/flang/runtime/assign.cpp
@@ -199,19 +199,17 @@ static void DoScalarDefinedAssignment(const Descriptor &to,
}
static void DoElementalDefinedAssignment(const Descriptor &to,
- const Descriptor &from, const typeInfo::SpecialBinding &special) {
+ const Descriptor &from, const typeInfo::DerivedType &derived,
+ const typeInfo::SpecialBinding &special) {
SubscriptValue toAt[maxRank], fromAt[maxRank];
to.GetLowerBounds(toAt);
from.GetLowerBounds(fromAt);
StaticDescriptor<maxRank, true, 8 /*?*/> statDesc[2];
Descriptor &toElementDesc{statDesc[0].descriptor()};
Descriptor &fromElementDesc{statDesc[1].descriptor()};
- toElementDesc = to;
- toElementDesc.raw().attribute = CFI_attribute_pointer;
- toElementDesc.raw().rank = 0;
- fromElementDesc = from;
- fromElementDesc.raw().attribute = CFI_attribute_pointer;
- fromElementDesc.raw().rank = 0;
+ toElementDesc.Establish(derived, nullptr, 0, nullptr, CFI_attribute_pointer);
+ fromElementDesc.Establish(
+ derived, nullptr, 0, nullptr, CFI_attribute_pointer);
for (std::size_t toElements{to.Elements()}; toElements-- > 0;
to.IncrementSubscripts(toAt), from.IncrementSubscripts(fromAt)) {
toElementDesc.set_base_addr(to.Element<char>(toAt));
@@ -268,7 +266,7 @@ static void Assign(
}
if (const auto *special{toDerived->FindSpecialBinding(
typeInfo::SpecialBinding::Which::ElementalAssignment)}) {
- return DoElementalDefinedAssignment(to, from, *special);
+ return DoElementalDefinedAssignment(to, from, *toDerived, *special);
}
}
if ((flags & NeedFinalization) && toDerived->noFinalizationNeeded()) {
More information about the flang-commits
mailing list