Skip to content

Commit cf780b2

Browse files
committed
[region-isolation] Remove two sources of copying PartitionOps.
Was experimenting with making PartitionOps a noncopyable type and I discovered these places where we copy PartitionOps when we could use a const reference. It is good not to copy PartitionOps since they potentially contain a heap allocated array. Sadly, my change to make PartitionOps noncopyable will have to wait until a forthcoming commit here I overhaul how we emit errors since that older code copies PartitionOps a lot and I would rather just delete that code and then fix PartitionOps. But these are on the surface safe changes that makes sense to get in separately to make that next patch easier to review.
1 parent c336f3a commit cf780b2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ struct PartitionOpEvaluator {
748748
}
749749

750750
/// Apply \p op to the partition op.
751-
void apply(PartitionOp op) {
751+
void apply(const PartitionOp &op) const {
752752
if (emitLog) {
753753
REGIONBASEDISOLATION_VERBOSE_LOG(llvm::dbgs() << "Applying: ";
754754
op.print(llvm::dbgs()));

lib/SILOptimizer/Mandatory/TransferNonSendable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ class BlockPartitionState {
13891389
bool recomputeExitFromEntry() {
13901390
Partition workingPartition = entryPartition;
13911391
PartitionOpEvaluator eval(workingPartition);
1392-
for (auto partitionOp : blockPartitionOps) {
1392+
for (const auto &partitionOp : blockPartitionOps) {
13931393
// By calling apply without providing a `handleFailure` closure, errors
13941394
// will be suppressed
13951395
eval.apply(partitionOp);
@@ -1421,7 +1421,7 @@ class BlockPartitionState {
14211421
os << "exit partition: ";
14221422
exitPartition.print(os);
14231423
os << "instructions:\n┌──────────╼\n";
1424-
for (PartitionOp op : blockPartitionOps) {
1424+
for (const auto &op : blockPartitionOps) {
14251425
os << "";
14261426
op.print(os, true /*extra space*/);
14271427
}

0 commit comments

Comments
 (0)