Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions flang-rt/lib/runtime/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,15 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
if (mustDeallocateLHS) {
// Convert the LHS into a temporary, then make it look deallocated.
toDeallocate_ = &tempDescriptor_.descriptor();
persist_ = true; // tempDescriptor_ state must outlive child tickets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general idea here is that by delaying conditionally setting persist, we can avoid persisting the allocation under some conditions and avoid the overhead of a trip through the work queue in those cases, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it was being set unconditionally, so it would be true even when the child task was run immediately as BeginDestroy or whatever, and that caused a later no-op suspension and resumption.

std::memcpy(
reinterpret_cast<void *>(toDeallocate_), &to_, to_.SizeInBytes());
to_.set_base_addr(nullptr);
if (toDerived_ && (flags_ & NeedFinalization)) {
if (int status{workQueue.BeginFinalize(*toDeallocate_, *toDerived_)};
status != StatOk && status != StatContinue) {
int status{workQueue.BeginFinalize(*toDeallocate_, *toDerived_)};
if (status == StatContinue) {
// tempDescriptor_ state must outlive pending child ticket
persist_ = true;
} else if (status != StatOk) {
return status;
}
flags_ &= ~NeedFinalization;
Expand All @@ -304,6 +306,9 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) {
if (int stat{ReturnError(
workQueue.terminator(), newFrom.Allocate(kNoAsyncObject))};
stat != StatOk) {
if (stat == StatContinue) {
persist_ = true;
}
return stat;
}
if (HasDynamicComponent(*from_)) {
Expand Down Expand Up @@ -507,6 +512,7 @@ RT_API_ATTRS int AssignTicket::Continue(WorkQueue &workQueue) {
}
}
if (persist_) {
// tempDescriptor_ must outlive pending child ticket(s)
done_ = true;
return StatContinue;
} else {
Expand Down
Loading