Skip to content

Commit 2007bad

Browse files
committed
[blot-map-vector] Merge blot/erase => erase.
They do the same thing.
1 parent e1ca63c commit 2007bad

File tree

7 files changed

+27
-34
lines changed

7 files changed

+27
-34
lines changed

include/swift/Basic/BlotMapVector.h

+7-14
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,8 @@ class BlotMapVector {
9595
/// vector, just zero out the key in the vector. This leaves iterators
9696
/// intact, but clients must be prepared for zeroed-out keys when iterating.
9797
///
98-
/// Return true if the element was erased.
99-
bool erase(const KeyT &Key) { return blot(Key); }
100-
101-
/// Eliminate the element at the given iterator. Instead of removing the
102-
/// element from the vector, just zero out the key in the vector. This
103-
/// leaves iterators intact, but clients must be prepared for zeroed-out
104-
/// keys when iterating.
105-
void erase(iterator I) { erase((*I)->first); }
106-
107-
/// Eliminate the element at `Key`. Instead of removing the element from the
108-
/// vector, it just zeros out the key in the vector. This leaves iterators
109-
/// intact, but clients must be prepared for zeroed-out keys when iterating.
110-
///
11198
/// Return true if the element was found and erased.
112-
bool blot(const KeyT &Key) {
99+
bool erase(const KeyT &Key) {
113100
typename MapT::iterator It = Map.find(Key);
114101
if (It == Map.end())
115102
return false;
@@ -118,6 +105,12 @@ class BlotMapVector {
118105
return true;
119106
}
120107

108+
/// Eliminate the element at the given iterator. Instead of removing the
109+
/// element from the vector, just zero out the key in the vector. This
110+
/// leaves iterators intact, but clients must be prepared for zeroed-out
111+
/// keys when iterating.
112+
void erase(iterator I) { erase((*I)->first); }
113+
121114
void clear() {
122115
Map.clear();
123116
Vector.clear();

lib/SILOptimizer/ARC/ARCBBState.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
4848
// effect of an intersection.
4949
auto Other = SuccBBState.PtrToBottomUpState.find(RefCountedValue);
5050
if (Other == SuccBBState.PtrToBottomUpState.end()) {
51-
PtrToBottomUpState.blot(RefCountedValue);
51+
PtrToBottomUpState.erase(RefCountedValue);
5252
continue;
5353
}
5454

@@ -58,7 +58,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
5858
// This has the effect of an intersection since we already checked earlier
5959
// that RefCountedValue was not blotted.
6060
if (!OtherRefCountedValue) {
61-
PtrToBottomUpState.blot(RefCountedValue);
61+
PtrToBottomUpState.erase(RefCountedValue);
6262
continue;
6363
}
6464

@@ -69,7 +69,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
6969
// of instructions which together semantically act as one ref count
7070
// increment. Merge the two states together.
7171
if (!RefCountState.merge(OtherRefCountState)) {
72-
PtrToBottomUpState.blot(RefCountedValue);
72+
PtrToBottomUpState.erase(RefCountedValue);
7373
}
7474
}
7575
}
@@ -102,7 +102,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
102102
// effect of an intersection.
103103
auto Other = PredBBState.PtrToTopDownState.find(RefCountedValue);
104104
if (Other == PredBBState.PtrToTopDownState.end()) {
105-
PtrToTopDownState.blot(RefCountedValue);
105+
PtrToTopDownState.erase(RefCountedValue);
106106
continue;
107107
}
108108

@@ -111,7 +111,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
111111
// If the other ref count value was blotted, blot our value and continue.
112112
// This has the effect of an intersection.
113113
if (!OtherRefCountedValue) {
114-
PtrToTopDownState.blot(RefCountedValue);
114+
PtrToTopDownState.erase(RefCountedValue);
115115
continue;
116116
}
117117

@@ -124,7 +124,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
124124
// ref counted value and continue.
125125
if (!RefCountState.merge(OtherRefCountState)) {
126126
DEBUG(llvm::dbgs() << "Failed to merge!\n");
127-
PtrToTopDownState.blot(RefCountedValue);
127+
PtrToTopDownState.erase(RefCountedValue);
128128
continue;
129129
}
130130
}

lib/SILOptimizer/ARC/ARCBBState.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ class ARCSequenceDataflowEvaluator::ARCBBState {
103103

104104
/// Blot \p Ptr.
105105
void clearBottomUpRefCountState(SILValue Ptr) {
106-
PtrToBottomUpState.blot(Ptr);
106+
PtrToBottomUpState.erase(Ptr);
107107
}
108108

109109
/// Blot \p Ptr.
110-
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.blot(Ptr); }
110+
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.erase(Ptr); }
111111

112112
void clearTopDownState() { PtrToTopDownState.clear(); }
113113
void clearBottomUpState() { PtrToBottomUpState.clear(); }

lib/SILOptimizer/ARC/ARCRegionState.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
6666
// effect of an intersection.
6767
auto Other = SuccRegionState.PtrToBottomUpState.find(RefCountedValue);
6868
if (Other == SuccRegionState.PtrToBottomUpState.end()) {
69-
PtrToBottomUpState.blot(RefCountedValue);
69+
PtrToBottomUpState.erase(RefCountedValue);
7070
continue;
7171
}
7272

@@ -76,7 +76,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
7676
// This has the effect of an intersection since we already checked earlier
7777
// that RefCountedValue was not blotted.
7878
if (!OtherRefCountedValue) {
79-
PtrToBottomUpState.blot(RefCountedValue);
79+
PtrToBottomUpState.erase(RefCountedValue);
8080
continue;
8181
}
8282

@@ -87,7 +87,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
8787
// of instructions which together semantically act as one ref count
8888
// increment. Merge the two states together.
8989
if (!RefCountState.merge(OtherRefCountState)) {
90-
PtrToBottomUpState.blot(RefCountedValue);
90+
PtrToBottomUpState.erase(RefCountedValue);
9191
}
9292
}
9393
}
@@ -123,7 +123,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
123123
// effect of an intersection.
124124
auto Other = PredRegionState.PtrToTopDownState.find(RefCountedValue);
125125
if (Other == PredRegionState.PtrToTopDownState.end()) {
126-
PtrToTopDownState.blot(RefCountedValue);
126+
PtrToTopDownState.erase(RefCountedValue);
127127
continue;
128128
}
129129

@@ -132,7 +132,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
132132
// If the other ref count value was blotted, blot our value and continue.
133133
// This has the effect of an intersection.
134134
if (!OtherRefCountedValue) {
135-
PtrToTopDownState.blot(RefCountedValue);
135+
PtrToTopDownState.erase(RefCountedValue);
136136
continue;
137137
}
138138

@@ -145,7 +145,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
145145
// ref counted value and continue.
146146
if (!RefCountState.merge(OtherRefCountState)) {
147147
DEBUG(llvm::dbgs() << "Failed to merge!\n");
148-
PtrToTopDownState.blot(RefCountedValue);
148+
PtrToTopDownState.erase(RefCountedValue);
149149
continue;
150150
}
151151
}

lib/SILOptimizer/ARC/ARCRegionState.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ class ARCRegionState {
121121

122122
/// Blot \p Ptr.
123123
void clearBottomUpRefCountState(SILValue Ptr) {
124-
PtrToBottomUpState.blot(Ptr);
124+
PtrToBottomUpState.erase(Ptr);
125125
}
126126

127127
/// Blot \p Ptr.
128-
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.blot(Ptr); }
128+
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.erase(Ptr); }
129129

130130
void clearTopDownState() { PtrToTopDownState.clear(); }
131131
void clearBottomUpState() { PtrToBottomUpState.clear(); }

lib/SILOptimizer/ARC/ARCSequenceOpts.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ bool ARCPairingContext::performMatching(
9595
MatchedPair |= Builder.matchedPair();
9696
auto &Set = Builder.getResult();
9797
for (auto *I : Set.Increments)
98-
IncToDecStateMap.blot(I);
98+
IncToDecStateMap.erase(I);
9999
for (auto *I : Set.Decrements)
100-
DecToIncStateMap.blot(I);
100+
DecToIncStateMap.erase(I);
101101

102102
// Add the Set to the callback. *NOTE* No instruction destruction can
103103
// happen here since we may remove instructions that are insertion points

lib/SILOptimizer/Transforms/SILCodeMotion.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,10 @@ void BBEnumTagDataflowState::mergePredecessorStates() {
506506
} while (PI != PE);
507507

508508
for (unsigned ID : CurBBValuesToBlot) {
509-
ValueToCaseMap.blot(ID);
509+
ValueToCaseMap.erase(ID);
510510
}
511511
for (unsigned ID : PredBBValuesToBlot) {
512-
EnumToEnumBBCaseListMap.blot(ID);
512+
EnumToEnumBBCaseListMap.erase(ID);
513513
}
514514
}
515515

0 commit comments

Comments
 (0)