summaryrefslogtreecommitdiff
path: root/flang-rt/lib/runtime/derived.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang-rt/lib/runtime/derived.cpp')
-rw-r--r--flang-rt/lib/runtime/derived.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/flang-rt/lib/runtime/derived.cpp b/flang-rt/lib/runtime/derived.cpp
index 2dddf079f91d..7e5067463162 100644
--- a/flang-rt/lib/runtime/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -63,7 +63,8 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
char *rawInstance{instance_.OffsetElement<char>()};
for (; !Componentwise::IsComplete(); SkipToNextComponent()) {
char *rawComponent{rawInstance + component_->offset()};
- if (component_->genre() == typeInfo::Component::Genre::Allocatable) {
+ if (component_->genre() == typeInfo::Component::Genre::Allocatable ||
+ component_->genre() == typeInfo::Component::Genre::AllocatableDevice) {
Descriptor &allocDesc{*reinterpret_cast<Descriptor *>(rawComponent)};
component_->EstablishDescriptor(
allocDesc, instance_, workQueue.terminator());
@@ -71,8 +72,9 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
// Explicit initialization of data pointers and
// non-allocatable non-automatic components
std::size_t bytes{component_->SizeInBytes(instance_)};
- std::memcpy(rawComponent, init, bytes);
- } else if (component_->genre() == typeInfo::Component::Genre::Pointer) {
+ runtime::memcpy(rawComponent, init, bytes);
+ } else if (component_->genre() == typeInfo::Component::Genre::Pointer ||
+ component_->genre() == typeInfo::Component::Genre::PointerDevice) {
// Data pointers without explicit initialization are established
// so that they are valid right-hand side targets of pointer
// assignment statements.
@@ -108,20 +110,20 @@ RT_API_ATTRS int InitializeTicket::Continue(WorkQueue &workQueue) {
chunk = done;
}
char *uninitialized{rawInstance + done * *stride};
- std::memcpy(uninitialized, rawInstance, chunk * *stride);
+ runtime::memcpy(uninitialized, rawInstance, chunk * *stride);
done += chunk;
}
} else {
for (std::size_t done{1}; done < elements_; ++done) {
char *uninitialized{rawInstance + done * *stride};
- std::memcpy(uninitialized, rawInstance, elementBytes);
+ runtime::memcpy(uninitialized, rawInstance, elementBytes);
}
}
} else { // one at a time with subscription
for (Elementwise::Advance(); !Elementwise::IsComplete();
Elementwise::Advance()) {
char *element{instance_.Element<char>(subscripts_)};
- std::memcpy(element, rawInstance, elementBytes);
+ runtime::memcpy(element, rawInstance, elementBytes);
}
}
}
@@ -143,7 +145,8 @@ RT_API_ATTRS int InitializeClone(const Descriptor &clone,
RT_API_ATTRS int InitializeCloneTicket::Continue(WorkQueue &workQueue) {
while (!IsComplete()) {
- if (component_->genre() == typeInfo::Component::Genre::Allocatable) {
+ if (component_->genre() == typeInfo::Component::Genre::Allocatable ||
+ component_->genre() == typeInfo::Component::Genre::AllocatableDevice) {
Descriptor &origDesc{*instance_.ElementComponent<Descriptor>(
subscripts_, component_->offset())};
if (origDesc.IsAllocated()) {
@@ -320,7 +323,9 @@ RT_API_ATTRS int FinalizeTicket::Begin(WorkQueue &workQueue) {
RT_API_ATTRS int FinalizeTicket::Continue(WorkQueue &workQueue) {
while (!IsComplete()) {
- if (component_->genre() == typeInfo::Component::Genre::Allocatable &&
+ if ((component_->genre() == typeInfo::Component::Genre::Allocatable ||
+ component_->genre() ==
+ typeInfo::Component::Genre::AllocatableDevice) &&
component_->category() == TypeCategory::Derived) {
// Component may be polymorphic or unlimited polymorphic. Need to use the
// dynamic type to check whether finalization is needed.
@@ -342,6 +347,7 @@ RT_API_ATTRS int FinalizeTicket::Continue(WorkQueue &workQueue) {
}
}
} else if (component_->genre() == typeInfo::Component::Genre::Allocatable ||
+ component_->genre() == typeInfo::Component::Genre::AllocatableDevice ||
component_->genre() == typeInfo::Component::Genre::Automatic) {
if (const typeInfo::DerivedType *compType{component_->derivedType()};
compType && !compType->noFinalizationNeeded()) {
@@ -424,7 +430,8 @@ RT_API_ATTRS int DestroyTicket::Continue(WorkQueue &workQueue) {
// Contrary to finalization, the order of deallocation does not matter.
while (!IsComplete()) {
const auto *componentDerived{component_->derivedType()};
- if (component_->genre() == typeInfo::Component::Genre::Allocatable) {
+ if (component_->genre() == typeInfo::Component::Genre::Allocatable ||
+ component_->genre() == typeInfo::Component::Genre::AllocatableDevice) {
if (fixedStride_ &&
(!componentDerived || componentDerived->noDestructionNeeded())) {
// common fast path, just deallocate in every element