File tree Expand file tree Collapse file tree 5 files changed +956
-50
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 5 files changed +956
-50
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,17 @@ class FrozenMultiMap {
9191 frozen = true ;
9292 }
9393
94+ // / Reset the frozen multimap in an unfrozen state with its storage cleared.
95+ void reset () {
96+ storage.clear ();
97+ frozen = false ;
98+ }
99+
94100 unsigned size () const { return storage.size (); }
95101 bool empty () const { return storage.empty (); }
96102
97103 struct iterator : std::iterator<std::forward_iterator_tag,
98- std::pair<Key, ArrayRef<Value> >> {
104+ std::pair<Key, PairToSecondEltRange >> {
99105 using base_iterator = typename decltype (storage)::iterator;
100106
101107 FrozenMultiMap ↦
@@ -159,9 +165,11 @@ class FrozenMultiMap {
159165 }
160166 };
161167
168+ using RangeType = llvm::iterator_range<iterator>;
169+
162170 // / Return a range of (key, ArrayRef<Value>) pairs. The keys are guaranteed to
163171 // / be in key sorted order and the ArrayRef<Value> are in insertion order.
164- llvm::iterator_range<iterator> getRange () const {
172+ RangeType getRange () const {
165173 assert (isFrozen () &&
166174 " Can not create range until data structure is frozen?!" );
167175 auto *self = const_cast <FrozenMultiMap *>(this );
Original file line number Diff line number Diff line change @@ -598,6 +598,28 @@ struct OwnedValueIntroducer {
598598 return OwnedValueIntroducer (value, *kind);
599599 }
600600
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+
601623 bool operator ==(const OwnedValueIntroducer &other) const {
602624 return value == other.value ;
603625 }
You can’t perform that action at this time.
0 commit comments