[RewriteStatepointsForGC] Further style/naming fixup [NFCI]

llvm-svn: 247217
This commit is contained in:
Philip Reames 2015-09-10 00:22:49 +00:00
parent 6fa09455ed
commit 34d7a7493d
1 changed files with 26 additions and 26 deletions

View File

@ -735,14 +735,14 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
// We use the order of insertion (DFS over the def/use graph) to provide a // We use the order of insertion (DFS over the def/use graph) to provide a
// stable deterministic ordering for visiting DenseMaps (which are unordered) // stable deterministic ordering for visiting DenseMaps (which are unordered)
// below. This is important for deterministic compilation. // below. This is important for deterministic compilation.
MapVector<Value *, BDVState> states; MapVector<Value *, BDVState> States;
// Recursively fill in all base defining values reachable from the initial // Recursively fill in all base defining values reachable from the initial
// one for which we don't already know a definite base value for // one for which we don't already know a definite base value for
/* scope */ { /* scope */ {
SmallVector<Value*, 16> Worklist; SmallVector<Value*, 16> Worklist;
Worklist.push_back(def); Worklist.push_back(def);
states.insert(std::make_pair(def, BDVState())); States.insert(std::make_pair(def, BDVState()));
while (!Worklist.empty()) { while (!Worklist.empty()) {
Value *Current = Worklist.pop_back_val(); Value *Current = Worklist.pop_back_val();
assert(!isKnownBaseResult(Current) && "why did it get added?"); assert(!isKnownBaseResult(Current) && "why did it get added?");
@ -755,7 +755,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
return; return;
assert(isExpectedBDVType(Base) && "the only non-base values " assert(isExpectedBDVType(Base) && "the only non-base values "
"we see should be base defining values"); "we see should be base defining values");
if (states.insert(std::make_pair(Base, BDVState())).second) if (States.insert(std::make_pair(Base, BDVState())).second)
Worklist.push_back(Base); Worklist.push_back(Base);
}; };
if (PHINode *Phi = dyn_cast<PHINode>(Current)) { if (PHINode *Phi = dyn_cast<PHINode>(Current)) {
@ -779,7 +779,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
#ifndef NDEBUG #ifndef NDEBUG
DEBUG(dbgs() << "States after initialization:\n"); DEBUG(dbgs() << "States after initialization:\n");
for (auto Pair : states) { for (auto Pair : States) {
DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n");
} }
#endif #endif
@ -789,22 +789,22 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
auto getStateForBDV = [&](Value *baseValue) { auto getStateForBDV = [&](Value *baseValue) {
if (isKnownBaseResult(baseValue)) if (isKnownBaseResult(baseValue))
return BDVState(baseValue); return BDVState(baseValue);
auto I = states.find(baseValue); auto I = States.find(baseValue);
assert(I != states.end() && "lookup failed!"); assert(I != States.end() && "lookup failed!");
return I->second; return I->second;
}; };
bool progress = true; bool progress = true;
while (progress) { while (progress) {
#ifndef NDEBUG #ifndef NDEBUG
size_t oldSize = states.size(); size_t oldSize = States.size();
#endif #endif
progress = false; progress = false;
// We're only changing values in this loop, thus safe to keep iterators. // We're only changing values in this loop, thus safe to keep iterators.
// Since this is computing a fixed point, the order of visit does not // Since this is computing a fixed point, the order of visit does not
// effect the result. TODO: We could use a worklist here and make this run // effect the result. TODO: We could use a worklist here and make this run
// much faster. // much faster.
for (auto Pair : states) { for (auto Pair : States) {
Value *BDV = Pair.first; Value *BDV = Pair.first;
assert(!isKnownBaseResult(BDV) && "why did it get added?"); assert(!isKnownBaseResult(BDV) && "why did it get added?");
@ -834,28 +834,28 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
calculateMeet.meetWith(getStateForInput(IE->getOperand(1))); calculateMeet.meetWith(getStateForInput(IE->getOperand(1)));
} }
BDVState oldState = states[BDV]; BDVState oldState = States[BDV];
BDVState newState = calculateMeet.getResult(); BDVState newState = calculateMeet.getResult();
if (oldState != newState) { if (oldState != newState) {
progress = true; progress = true;
states[BDV] = newState; States[BDV] = newState;
} }
} }
assert(oldSize <= states.size()); assert(oldSize <= States.size());
assert(oldSize == states.size() || progress); assert(oldSize == States.size() || progress);
} }
#ifndef NDEBUG #ifndef NDEBUG
DEBUG(dbgs() << "States after meet iteration:\n"); DEBUG(dbgs() << "States after meet iteration:\n");
for (auto Pair : states) { for (auto Pair : States) {
DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n"); DEBUG(dbgs() << " " << Pair.second << " for " << *Pair.first << "\n");
} }
#endif #endif
// Insert Phis for all conflicts // Insert Phis for all conflicts
// TODO: adjust naming patterns to avoid this order of iteration dependency // TODO: adjust naming patterns to avoid this order of iteration dependency
for (auto Pair : states) { for (auto Pair : States) {
Instruction *I = cast<Instruction>(Pair.first); Instruction *I = cast<Instruction>(Pair.first);
BDVState State = Pair.second; BDVState State = Pair.second;
assert(!isKnownBaseResult(I) && "why did it get added?"); assert(!isKnownBaseResult(I) && "why did it get added?");
@ -875,7 +875,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
EE->getIndexOperand(), EE->getIndexOperand(),
"base_ee", EE); "base_ee", EE);
BaseInst->setMetadata("is_base_value", MDNode::get(I->getContext(), {})); BaseInst->setMetadata("is_base_value", MDNode::get(I->getContext(), {}));
states[I] = BDVState(BDVState::Base, BaseInst); States[I] = BDVState(BDVState::Base, BaseInst);
} }
// Since we're joining a vector and scalar base, they can never be the // Since we're joining a vector and scalar base, they can never be the
@ -921,7 +921,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
Instruction *BaseInst = MakeBaseInstPlaceholder(I); Instruction *BaseInst = MakeBaseInstPlaceholder(I);
// Add metadata marking this as a base value // Add metadata marking this as a base value
BaseInst->setMetadata("is_base_value", MDNode::get(I->getContext(), {})); BaseInst->setMetadata("is_base_value", MDNode::get(I->getContext(), {}));
states[I] = BDVState(BDVState::Conflict, BaseInst); States[I] = BDVState(BDVState::Conflict, BaseInst);
} }
// Returns a instruction which produces the base pointer for a given // Returns a instruction which produces the base pointer for a given
@ -939,8 +939,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
Base = BDV; Base = BDV;
} else { } else {
// Either conflict or base. // Either conflict or base.
assert(states.count(BDV)); assert(States.count(BDV));
Base = states[BDV].getBase(); Base = States[BDV].getBase();
} }
assert(Base && "can't be null"); assert(Base && "can't be null");
// The cast is needed since base traversal may strip away bitcasts // The cast is needed since base traversal may strip away bitcasts
@ -955,7 +955,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
// Fixup all the inputs of the new PHIs. Visit order needs to be // Fixup all the inputs of the new PHIs. Visit order needs to be
// deterministic and predictable because we're naming newly created // deterministic and predictable because we're naming newly created
// instructions. // instructions.
for (auto Pair : states) { for (auto Pair : States) {
Instruction *BDV = cast<Instruction>(Pair.first); Instruction *BDV = cast<Instruction>(Pair.first);
BDVState state = Pair.second; BDVState state = Pair.second;
@ -1032,8 +1032,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
Value *Base = findBaseOrBDV(InVal, cache); Value *Base = findBaseOrBDV(InVal, cache);
if (!isKnownBaseResult(Base)) { if (!isKnownBaseResult(Base)) {
// Either conflict or base. // Either conflict or base.
assert(states.count(Base)); assert(States.count(Base));
Base = states[Base].getBase(); Base = States[Base].getBase();
assert(Base != nullptr && "unknown BDVState!"); assert(Base != nullptr && "unknown BDVState!");
} }
assert(Base && "can't be null"); assert(Base && "can't be null");
@ -1056,7 +1056,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
// Keys we sorted above for this purpose. Note that we are papering over a // Keys we sorted above for this purpose. Note that we are papering over a
// bigger problem with the algorithm above - it's visit order is not // bigger problem with the algorithm above - it's visit order is not
// deterministic. A larger change is needed to fix this. // deterministic. A larger change is needed to fix this.
for (auto Pair : states) { for (auto Pair : States) {
auto *BDV = Pair.first; auto *BDV = Pair.first;
auto State = Pair.second; auto State = Pair.second;
Value *Base = State.getBase(); Value *Base = State.getBase();
@ -1085,9 +1085,9 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
ReverseMap.erase(BaseI); ReverseMap.erase(BaseI);
BaseI->replaceAllUsesWith(Replacement); BaseI->replaceAllUsesWith(Replacement);
BaseI->eraseFromParent(); BaseI->eraseFromParent();
assert(states.count(BDV)); assert(States.count(BDV));
assert(states[BDV].isConflict() && states[BDV].getBase() == BaseI); assert(States[BDV].isConflict() && States[BDV].getBase() == BaseI);
states[BDV] = BDVState(BDVState::Conflict, Replacement); States[BDV] = BDVState(BDVState::Conflict, Replacement);
}; };
const DataLayout &DL = cast<Instruction>(def)->getModule()->getDataLayout(); const DataLayout &DL = cast<Instruction>(def)->getModule()->getDataLayout();
while (!Worklist.empty()) { while (!Worklist.empty()) {
@ -1110,7 +1110,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
// Cache all of our results so we can cheaply reuse them // Cache all of our results so we can cheaply reuse them
// NOTE: This is actually two caches: one of the base defining value // NOTE: This is actually two caches: one of the base defining value
// relation and one of the base pointer relation! FIXME // relation and one of the base pointer relation! FIXME
for (auto Pair : states) { for (auto Pair : States) {
auto *BDV = Pair.first; auto *BDV = Pair.first;
Value *base = Pair.second.getBase(); Value *base = Pair.second.getBase();
assert(BDV && base); assert(BDV && base);