Skip to content

Commit 631ad05

Browse files
authored
Merge pull request #68712 from gottesmm/pr-8f27a8f70da71ca09280019764955e3b64882190
[isolation-regions] Eliminate unnecessary heap allocations used for temporary values
2 parents 439aa4b + 8d46cc8 commit 631ad05

File tree

3 files changed

+312
-271
lines changed

3 files changed

+312
-271
lines changed

include/swift/SILOptimizer/Utils/PartitionUtils.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ struct Region {
4444

4545
using namespace PartitionPrimitives;
4646

47-
// PartitionOpKind represents the different kinds of PartitionOps that
48-
// SILInstructions can be translated to
47+
/// PartitionOpKind represents the different kinds of PartitionOps that
48+
/// SILInstructions can be translated to
4949
enum class PartitionOpKind : uint8_t {
50-
// Assign one value to the region of another, takes two args, second arg
51-
// must already be tracked with a non-consumed region
50+
/// Assign one value to the region of another, takes two args, second arg
51+
/// must already be tracked with a non-consumed region
5252
Assign,
5353

54-
// Assign one value to a fresh region, takes one arg.
54+
/// Assign one value to a fresh region, takes one arg.
5555
AssignFresh,
5656

57-
// Consume the region of a value if not already consumed, takes one arg.
58-
Consume,
59-
60-
// Merge the regions of two values, takes two args, both must be from
61-
// non-consumed regions.
57+
/// Merge the regions of two values, takes two args, both must be from
58+
/// non-consumed regions.
6259
Merge,
6360

64-
// Require the region of a value to be non-consumed, takes one arg.
65-
Require
61+
/// Consume the region of a value if not already consumed, takes one arg.
62+
Transfer,
63+
64+
/// Require the region of a value to be non-consumed, takes one arg.
65+
Require,
6666
};
6767

6868
// PartitionOp represents a primitive operation that can be performed on
@@ -108,11 +108,9 @@ class PartitionOp {
108108
return PartitionOp(PartitionOpKind::AssignFresh, tgt, sourceInst);
109109
}
110110

111-
static PartitionOp Consume(Element tgt,
112-
SILInstruction *sourceInst = nullptr,
113-
Expr *sourceExpr = nullptr) {
114-
return PartitionOp(PartitionOpKind::Consume, tgt,
115-
sourceInst, sourceExpr);
111+
static PartitionOp Transfer(Element tgt, SILInstruction *sourceInst = nullptr,
112+
Expr *sourceExpr = nullptr) {
113+
return PartitionOp(PartitionOpKind::Transfer, tgt, sourceInst, sourceExpr);
116114
}
117115

118116
static PartitionOp Merge(Element tgt1, Element tgt2,
@@ -164,7 +162,7 @@ class PartitionOp {
164162
case PartitionOpKind::AssignFresh:
165163
os << "assign_fresh %%" << OpArgs[0] << "\n";
166164
break;
167-
case PartitionOpKind::Consume:
165+
case PartitionOpKind::Transfer:
168166
os << "consume %%" << OpArgs[0] << "\n";
169167
break;
170168
case PartitionOpKind::Merge:
@@ -425,7 +423,7 @@ class Partition {
425423
fresh_label = Region(fresh_label + 1);
426424
canonical = false;
427425
break;
428-
case PartitionOpKind::Consume:
426+
case PartitionOpKind::Transfer:
429427
assert(op.OpArgs.size() == 1 &&
430428
"Consume PartitionOp should be passed 1 argument");
431429
assert(labels.count(op.OpArgs[0]) &&

0 commit comments

Comments
 (0)