@@ -63,15 +63,16 @@ static inline llvm::hash_code hash_value(ValueKind K) {
63
63
// / What constraint does the given use of an SSA value put on the lifetime of
64
64
// / the given SSA value.
65
65
// /
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.
71
72
enum class UseLifetimeConstraint {
72
73
// / This use requires the SSA value to be live after the given instruction's
73
74
// / execution.
74
- MustBeLive ,
75
+ NonLifetimeEnding ,
75
76
76
77
// / This use invalidates the given SSA value.
77
78
// /
@@ -81,7 +82,7 @@ enum class UseLifetimeConstraint {
81
82
// / guaranteed (i.e. shared borrow) semantics this means that the program
82
83
// / has left the scope of the borrowed SSA value and said value can not be
83
84
// / used.
84
- MustBeInvalidated ,
85
+ LifetimeEnding ,
85
86
};
86
87
87
88
llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
@@ -174,9 +175,9 @@ struct ValueOwnershipKind {
174
175
case ValueOwnershipKind::None:
175
176
case ValueOwnershipKind::Guaranteed:
176
177
case ValueOwnershipKind::Unowned:
177
- return UseLifetimeConstraint::MustBeLive ;
178
+ return UseLifetimeConstraint::NonLifetimeEnding ;
178
179
case ValueOwnershipKind::Owned:
179
- return UseLifetimeConstraint::MustBeInvalidated ;
180
+ return UseLifetimeConstraint::LifetimeEnding ;
180
181
}
181
182
llvm_unreachable (" covered switch" );
182
183
}
@@ -523,7 +524,8 @@ struct OperandOwnershipKindMap {
523
524
if (ValueOwnershipKind (index) == kind) {
524
525
continue ;
525
526
}
526
- map.add (ValueOwnershipKind (index), UseLifetimeConstraint::MustBeLive);
527
+ map.add (ValueOwnershipKind (index),
528
+ UseLifetimeConstraint::NonLifetimeEnding);
527
529
}
528
530
return map;
529
531
}
@@ -548,7 +550,8 @@ struct OperandOwnershipKindMap {
548
550
unsigned index = 0 ;
549
551
unsigned end = unsigned (ValueOwnershipKind::LastValueOwnershipKind) + 1 ;
550
552
while (index != end) {
551
- map.add (ValueOwnershipKind (index), UseLifetimeConstraint::MustBeLive);
553
+ map.add (ValueOwnershipKind (index),
554
+ UseLifetimeConstraint::NonLifetimeEnding);
552
555
++index;
553
556
}
554
557
return map;
@@ -574,7 +577,7 @@ struct OperandOwnershipKindMap {
574
577
575
578
void addCompatibilityConstraint (ValueOwnershipKind kind,
576
579
UseLifetimeConstraint constraint) {
577
- add (ValueOwnershipKind::None, UseLifetimeConstraint::MustBeLive );
580
+ add (ValueOwnershipKind::None, UseLifetimeConstraint::NonLifetimeEnding );
578
581
add (kind, constraint);
579
582
}
580
583
@@ -697,14 +700,14 @@ class Operand {
697
700
698
701
// / Returns true if this operand acts as a use that consumes its associated
699
702
// / value.
700
- bool isConsumingUse () const {
703
+ bool isLifetimeEnding () const {
701
704
// Type dependent uses can never be consuming and do not have valid
702
705
// ownership maps since they do not participate in the ownership system.
703
706
if (isTypeDependent ())
704
707
return false ;
705
708
auto map = getOwnershipKindMap ();
706
709
auto constraint = map.getLifetimeConstraint (get ().getOwnershipKind ());
707
- return constraint == UseLifetimeConstraint::MustBeInvalidated ;
710
+ return constraint == UseLifetimeConstraint::LifetimeEnding ;
708
711
}
709
712
710
713
SILBasicBlock *getParentBlock () const ;
@@ -792,9 +795,9 @@ class ConsumingUseIterator : public ValueBaseUseIterator {
792
795
explicit ConsumingUseIterator (Operand *cur) : ValueBaseUseIterator(cur) {}
793
796
ConsumingUseIterator &operator ++() {
794
797
assert (Cur && " incrementing past end()!" );
795
- assert (Cur->isConsumingUse ());
798
+ assert (Cur->isLifetimeEnding ());
796
799
while ((Cur = Cur->NextUse )) {
797
- if (Cur->isConsumingUse ())
800
+ if (Cur->isLifetimeEnding ())
798
801
break ;
799
802
}
800
803
return *this ;
@@ -810,7 +813,7 @@ class ConsumingUseIterator : public ValueBaseUseIterator {
810
813
inline ValueBase::consuming_use_iterator
811
814
ValueBase::consuming_use_begin () const {
812
815
auto cur = FirstUse;
813
- while (cur && !cur->isConsumingUse ()) {
816
+ while (cur && !cur->isLifetimeEnding ()) {
814
817
cur = cur->NextUse ;
815
818
}
816
819
return ValueBase::consuming_use_iterator (cur);
@@ -825,9 +828,9 @@ class NonConsumingUseIterator : public ValueBaseUseIterator {
825
828
explicit NonConsumingUseIterator (Operand *cur) : ValueBaseUseIterator(cur) {}
826
829
NonConsumingUseIterator &operator ++() {
827
830
assert (Cur && " incrementing past end()!" );
828
- assert (!Cur->isConsumingUse ());
831
+ assert (!Cur->isLifetimeEnding ());
829
832
while ((Cur = Cur->NextUse )) {
830
- if (!Cur->isConsumingUse ())
833
+ if (!Cur->isLifetimeEnding ())
831
834
break ;
832
835
}
833
836
return *this ;
@@ -843,7 +846,7 @@ class NonConsumingUseIterator : public ValueBaseUseIterator {
843
846
inline ValueBase::non_consuming_use_iterator
844
847
ValueBase::non_consuming_use_begin () const {
845
848
auto cur = FirstUse;
846
- while (cur && cur->isConsumingUse ()) {
849
+ while (cur && cur->isLifetimeEnding ()) {
847
850
cur = cur->NextUse ;
848
851
}
849
852
return ValueBase::non_consuming_use_iterator (cur);
@@ -880,7 +883,7 @@ inline Operand *ValueBase::getSingleUse() const {
880
883
inline Operand *ValueBase::getSingleConsumingUse () const {
881
884
Operand *result = nullptr ;
882
885
for (auto *op : getUses ()) {
883
- if (op->isConsumingUse ()) {
886
+ if (op->isLifetimeEnding ()) {
884
887
if (result) {
885
888
return nullptr ;
886
889
}
0 commit comments