[blot-map-vector] Merge blot/erase => erase.

They do the same thing.
This commit is contained in:
Michael Gottesman
2018-04-02 10:07:15 -07:00
parent e1ca63ccb8
commit 2007badf6b
7 changed files with 27 additions and 34 deletions

View File

@@ -95,21 +95,8 @@ class BlotMapVector {
/// vector, just zero out the key in the vector. This leaves iterators
/// intact, but clients must be prepared for zeroed-out keys when iterating.
///
/// Return true if the element was erased.
bool erase(const KeyT &Key) { return blot(Key); }
/// Eliminate the element at the given iterator. Instead of removing the
/// element from the vector, just zero out the key in the vector. This
/// leaves iterators intact, but clients must be prepared for zeroed-out
/// keys when iterating.
void erase(iterator I) { erase((*I)->first); }
/// Eliminate the element at `Key`. Instead of removing the element from the
/// vector, it just zeros out the key in the vector. This leaves iterators
/// intact, but clients must be prepared for zeroed-out keys when iterating.
///
/// Return true if the element was found and erased.
bool blot(const KeyT &Key) {
bool erase(const KeyT &Key) {
typename MapT::iterator It = Map.find(Key);
if (It == Map.end())
return false;
@@ -118,6 +105,12 @@ class BlotMapVector {
return true;
}
/// Eliminate the element at the given iterator. Instead of removing the
/// element from the vector, just zero out the key in the vector. This
/// leaves iterators intact, but clients must be prepared for zeroed-out
/// keys when iterating.
void erase(iterator I) { erase((*I)->first); }
void clear() {
Map.clear();
Vector.clear();

View File

@@ -48,7 +48,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
// effect of an intersection.
auto Other = SuccBBState.PtrToBottomUpState.find(RefCountedValue);
if (Other == SuccBBState.PtrToBottomUpState.end()) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
continue;
}
@@ -58,7 +58,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
// This has the effect of an intersection since we already checked earlier
// that RefCountedValue was not blotted.
if (!OtherRefCountedValue) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
continue;
}
@@ -69,7 +69,7 @@ void ARCBBState::mergeSuccBottomUp(ARCBBState &SuccBBState) {
// of instructions which together semantically act as one ref count
// increment. Merge the two states together.
if (!RefCountState.merge(OtherRefCountState)) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
}
}
}
@@ -102,7 +102,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
// effect of an intersection.
auto Other = PredBBState.PtrToTopDownState.find(RefCountedValue);
if (Other == PredBBState.PtrToTopDownState.end()) {
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
@@ -111,7 +111,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
// If the other ref count value was blotted, blot our value and continue.
// This has the effect of an intersection.
if (!OtherRefCountedValue) {
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
@@ -124,7 +124,7 @@ void ARCBBState::mergePredTopDown(ARCBBState &PredBBState) {
// ref counted value and continue.
if (!RefCountState.merge(OtherRefCountState)) {
DEBUG(llvm::dbgs() << "Failed to merge!\n");
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
}

View File

@@ -103,11 +103,11 @@ public:
/// Blot \p Ptr.
void clearBottomUpRefCountState(SILValue Ptr) {
PtrToBottomUpState.blot(Ptr);
PtrToBottomUpState.erase(Ptr);
}
/// Blot \p Ptr.
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.blot(Ptr); }
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.erase(Ptr); }
void clearTopDownState() { PtrToTopDownState.clear(); }
void clearBottomUpState() { PtrToBottomUpState.clear(); }

View File

@@ -66,7 +66,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
// effect of an intersection.
auto Other = SuccRegionState.PtrToBottomUpState.find(RefCountedValue);
if (Other == SuccRegionState.PtrToBottomUpState.end()) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
continue;
}
@@ -76,7 +76,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
// This has the effect of an intersection since we already checked earlier
// that RefCountedValue was not blotted.
if (!OtherRefCountedValue) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
continue;
}
@@ -87,7 +87,7 @@ void ARCRegionState::mergeSuccBottomUp(ARCRegionState &SuccRegionState) {
// of instructions which together semantically act as one ref count
// increment. Merge the two states together.
if (!RefCountState.merge(OtherRefCountState)) {
PtrToBottomUpState.blot(RefCountedValue);
PtrToBottomUpState.erase(RefCountedValue);
}
}
}
@@ -123,7 +123,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
// effect of an intersection.
auto Other = PredRegionState.PtrToTopDownState.find(RefCountedValue);
if (Other == PredRegionState.PtrToTopDownState.end()) {
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
@@ -132,7 +132,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
// If the other ref count value was blotted, blot our value and continue.
// This has the effect of an intersection.
if (!OtherRefCountedValue) {
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
@@ -145,7 +145,7 @@ void ARCRegionState::mergePredTopDown(ARCRegionState &PredRegionState) {
// ref counted value and continue.
if (!RefCountState.merge(OtherRefCountState)) {
DEBUG(llvm::dbgs() << "Failed to merge!\n");
PtrToTopDownState.blot(RefCountedValue);
PtrToTopDownState.erase(RefCountedValue);
continue;
}
}

View File

@@ -121,11 +121,11 @@ public:
/// Blot \p Ptr.
void clearBottomUpRefCountState(SILValue Ptr) {
PtrToBottomUpState.blot(Ptr);
PtrToBottomUpState.erase(Ptr);
}
/// Blot \p Ptr.
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.blot(Ptr); }
void clearTopDownRefCountState(SILValue Ptr) { PtrToTopDownState.erase(Ptr); }
void clearTopDownState() { PtrToTopDownState.clear(); }
void clearBottomUpState() { PtrToBottomUpState.clear(); }

View File

@@ -95,9 +95,9 @@ bool ARCPairingContext::performMatching(
MatchedPair |= Builder.matchedPair();
auto &Set = Builder.getResult();
for (auto *I : Set.Increments)
IncToDecStateMap.blot(I);
IncToDecStateMap.erase(I);
for (auto *I : Set.Decrements)
DecToIncStateMap.blot(I);
DecToIncStateMap.erase(I);
// Add the Set to the callback. *NOTE* No instruction destruction can
// happen here since we may remove instructions that are insertion points

View File

@@ -506,10 +506,10 @@ void BBEnumTagDataflowState::mergePredecessorStates() {
} while (PI != PE);
for (unsigned ID : CurBBValuesToBlot) {
ValueToCaseMap.blot(ID);
ValueToCaseMap.erase(ID);
}
for (unsigned ID : PredBBValuesToBlot) {
EnumToEnumBBCaseListMap.blot(ID);
EnumToEnumBBCaseListMap.erase(ID);
}
}