File tree 5 files changed +956
-50
lines changed
lib/SILOptimizer/Transforms
5 files changed +956
-50
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,17 @@ class FrozenMultiMap {
91
91
frozen = true ;
92
92
}
93
93
94
+ // / Reset the frozen multimap in an unfrozen state with its storage cleared.
95
+ void reset () {
96
+ storage.clear ();
97
+ frozen = false ;
98
+ }
99
+
94
100
unsigned size () const { return storage.size (); }
95
101
bool empty () const { return storage.empty (); }
96
102
97
103
struct iterator : std::iterator<std::forward_iterator_tag,
98
- std::pair<Key, ArrayRef<Value> >> {
104
+ std::pair<Key, PairToSecondEltRange >> {
99
105
using base_iterator = typename decltype (storage)::iterator;
100
106
101
107
FrozenMultiMap ↦
@@ -159,9 +165,11 @@ class FrozenMultiMap {
159
165
}
160
166
};
161
167
168
+ using RangeType = llvm::iterator_range<iterator>;
169
+
162
170
// / Return a range of (key, ArrayRef<Value>) pairs. The keys are guaranteed to
163
171
// / be in key sorted order and the ArrayRef<Value> are in insertion order.
164
- llvm::iterator_range<iterator> getRange () const {
172
+ RangeType getRange () const {
165
173
assert (isFrozen () &&
166
174
" Can not create range until data structure is frozen?!" );
167
175
auto *self = const_cast <FrozenMultiMap *>(this );
Original file line number Diff line number Diff line change @@ -598,6 +598,28 @@ struct OwnedValueIntroducer {
598
598
return OwnedValueIntroducer (value, *kind);
599
599
}
600
600
601
+ // / Returns true if this owned introducer is able to be converted into a
602
+ // / guaranteed form if none of its uses are consuming uses (looking through
603
+ // / forwarding uses).
604
+ bool isConvertableToGuaranteed () const {
605
+ switch (kind) {
606
+ case OwnedValueIntroducerKind::Copy:
607
+ case OwnedValueIntroducerKind::LoadCopy:
608
+ return true ;
609
+ case OwnedValueIntroducerKind::Apply:
610
+ case OwnedValueIntroducerKind::BeginApply:
611
+ case OwnedValueIntroducerKind::TryApply:
612
+ case OwnedValueIntroducerKind::LoadTake:
613
+ case OwnedValueIntroducerKind::Phi:
614
+ case OwnedValueIntroducerKind::FunctionArgument:
615
+ case OwnedValueIntroducerKind::PartialApplyInit:
616
+ case OwnedValueIntroducerKind::AllocBoxInit:
617
+ case OwnedValueIntroducerKind::AllocRefInit:
618
+ return false ;
619
+ }
620
+ llvm_unreachable (" Covered switch isn't covered?!" );
621
+ }
622
+
601
623
bool operator ==(const OwnedValueIntroducer &other) const {
602
624
return value == other.value ;
603
625
}
You can’t perform that action at this time.
0 commit comments