Skip to content

Commit 2ef7a21

Browse files
committed
[ownership] Rename the cases of UseLifetimeConstraint to use clearer language
Specifically, * MustBeLive -> NonLifetimeEnding * MustBeInvalidated -> LifetimeEnding
1 parent 0aa41bc commit 2ef7a21

File tree

6 files changed

+156
-151
lines changed

6 files changed

+156
-151
lines changed

include/swift/SIL/SILValue.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ static inline llvm::hash_code hash_value(ValueKind K) {
6363
/// What constraint does the given use of an SSA value put on the lifetime of
6464
/// the given SSA value.
6565
///
66-
/// There are two possible constraints: MustBeLive and
67-
/// MustBeInvalidated. MustBeLive means that the SSA value must be able to be
68-
/// used in a valid way at the given use point. MustBeInvalidated means that any
69-
/// use of given SSA value after this instruction on any path through this
70-
/// instruction.
66+
/// There are two possible constraints: NonLifetimeEnding and
67+
/// LifetimeEnding. NonLifetimeEnding means that the SSA value must be
68+
/// able to be used in a valid way at the given use
69+
/// point. LifetimeEnding means that the value has been invalidated at
70+
/// the given use point and any uses reachable from that point are
71+
/// invalid in SIL causing a SIL verifier error.
7172
enum class UseLifetimeConstraint {
7273
/// This use requires the SSA value to be live after the given instruction's
7374
/// execution.
74-
MustBeLive,
75+
NonLifetimeEnding,
7576

7677
/// This use invalidates the given SSA value.
7778
///
@@ -81,7 +82,7 @@ enum class UseLifetimeConstraint {
8182
/// guaranteed (i.e. shared borrow) semantics this means that the program
8283
/// has left the scope of the borrowed SSA value and said value can not be
8384
/// used.
84-
MustBeInvalidated,
85+
LifetimeEnding,
8586
};
8687

8788
llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
@@ -174,9 +175,9 @@ struct ValueOwnershipKind {
174175
case ValueOwnershipKind::None:
175176
case ValueOwnershipKind::Guaranteed:
176177
case ValueOwnershipKind::Unowned:
177-
return UseLifetimeConstraint::MustBeLive;
178+
return UseLifetimeConstraint::NonLifetimeEnding;
178179
case ValueOwnershipKind::Owned:
179-
return UseLifetimeConstraint::MustBeInvalidated;
180+
return UseLifetimeConstraint::LifetimeEnding;
180181
}
181182
llvm_unreachable("covered switch");
182183
}
@@ -523,7 +524,8 @@ struct OperandOwnershipKindMap {
523524
if (ValueOwnershipKind(index) == kind) {
524525
continue;
525526
}
526-
map.add(ValueOwnershipKind(index), UseLifetimeConstraint::MustBeLive);
527+
map.add(ValueOwnershipKind(index),
528+
UseLifetimeConstraint::NonLifetimeEnding);
527529
}
528530
return map;
529531
}
@@ -548,7 +550,8 @@ struct OperandOwnershipKindMap {
548550
unsigned index = 0;
549551
unsigned end = unsigned(ValueOwnershipKind::LastValueOwnershipKind) + 1;
550552
while (index != end) {
551-
map.add(ValueOwnershipKind(index), UseLifetimeConstraint::MustBeLive);
553+
map.add(ValueOwnershipKind(index),
554+
UseLifetimeConstraint::NonLifetimeEnding);
552555
++index;
553556
}
554557
return map;
@@ -574,7 +577,7 @@ struct OperandOwnershipKindMap {
574577

575578
void addCompatibilityConstraint(ValueOwnershipKind kind,
576579
UseLifetimeConstraint constraint) {
577-
add(ValueOwnershipKind::None, UseLifetimeConstraint::MustBeLive);
580+
add(ValueOwnershipKind::None, UseLifetimeConstraint::NonLifetimeEnding);
578581
add(kind, constraint);
579582
}
580583

@@ -704,7 +707,7 @@ class Operand {
704707
return false;
705708
auto map = getOwnershipKindMap();
706709
auto constraint = map.getLifetimeConstraint(get().getOwnershipKind());
707-
return constraint == UseLifetimeConstraint::MustBeInvalidated;
710+
return constraint == UseLifetimeConstraint::LifetimeEnding;
708711
}
709712

710713
SILBasicBlock *getParentBlock() const;

0 commit comments

Comments
 (0)