Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,22 @@ void OrderedAssignmentRewriter::generateSaveEntity(
assert(inserted.second && "entity must have been emplaced");
(void)inserted;
} else {
generateCleanupIfAny(oldYield);
if (constructStack.empty() &&
mlir::isa<hlfir::RegionAssignOp>(region.getParentOp())) {
// Here the clean-up code is inserted after the original
// RegionAssignOp, so that the assignment code happens
// before the cleanup. We do this only for standalone
// operations, because the clean-up is handled specially
// during lowering of the parent constructs if any
// (e.g. see generateNoneElementalCleanupIfAny for
// WhereOp).
auto insertionPoint = builder.saveInsertionPoint();
builder.setInsertionPointAfter(region.getParentOp());
generateCleanupIfAny(oldYield);
builder.restoreInsertionPoint(insertionPoint);
} else {
generateCleanupIfAny(oldYield);
}
}
}

Expand Down
Loading