1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[CodeGen, Transforms] Use *Map::lookup (NFC)

This commit is contained in:
Kazu Hirata 2020-12-27 09:57:27 -08:00
parent 41179ce945
commit b3da88360d
8 changed files with 10 additions and 40 deletions

View File

@ -388,10 +388,7 @@ namespace llvm {
/// Returns an existing SUnit for this MI, or nullptr. /// Returns an existing SUnit for this MI, or nullptr.
inline SUnit *ScheduleDAGInstrs::getSUnit(MachineInstr *MI) const { inline SUnit *ScheduleDAGInstrs::getSUnit(MachineInstr *MI) const {
DenseMap<MachineInstr*, SUnit*>::const_iterator I = MISUnitMap.find(MI); return MISUnitMap.lookup(MI);
if (I == MISUnitMap.end())
return nullptr;
return I->second;
} }
} // end namespace llvm } // end namespace llvm

View File

@ -787,8 +787,7 @@ public:
} }
unsigned getStringTypeLoc(const DIStringType *ST) const { unsigned getStringTypeLoc(const DIStringType *ST) const {
auto I = StringTypeLocMap.find(ST); return StringTypeLocMap.lookup(ST);
return I != StringTypeLocMap.end() ? I->second : 0;
} }
void addStringTypeLoc(const DIStringType *ST, unsigned Loc) { void addStringTypeLoc(const DIStringType *ST, unsigned Loc) {

View File

@ -369,10 +369,7 @@ static void initSlots2Values(const Function &F,
const Value* PerFunctionMIParsingState::getIRValue(unsigned Slot) { const Value* PerFunctionMIParsingState::getIRValue(unsigned Slot) {
if (Slots2Values.empty()) if (Slots2Values.empty())
initSlots2Values(MF.getFunction(), Slots2Values); initSlots2Values(MF.getFunction(), Slots2Values);
auto ValueInfo = Slots2Values.find(Slot); return Slots2Values.lookup(Slot);
if (ValueInfo == Slots2Values.end())
return nullptr;
return ValueInfo->second;
} }
namespace { namespace {
@ -3169,10 +3166,7 @@ static void initSlots2BasicBlocks(
static const BasicBlock *getIRBlockFromSlot( static const BasicBlock *getIRBlockFromSlot(
unsigned Slot, unsigned Slot,
const DenseMap<unsigned, const BasicBlock *> &Slots2BasicBlocks) { const DenseMap<unsigned, const BasicBlock *> &Slots2BasicBlocks) {
auto BlockInfo = Slots2BasicBlocks.find(Slot); return Slots2BasicBlocks.lookup(Slot);
if (BlockInfo == Slots2BasicBlocks.end())
return nullptr;
return BlockInfo->second;
} }
const BasicBlock *MIParser::getIRBlock(unsigned Slot) { const BasicBlock *MIParser::getIRBlock(unsigned Slot) {

View File

@ -273,12 +273,7 @@ bool PointerReplacer::collectUsers(Instruction &I) {
return true; return true;
} }
Value *PointerReplacer::getReplacement(Value *V) { Value *PointerReplacer::getReplacement(Value *V) { return WorkMap.lookup(V); }
auto Loc = WorkMap.find(V);
if (Loc != WorkMap.end())
return Loc->second;
return nullptr;
}
void PointerReplacer::replace(Instruction *I) { void PointerReplacer::replace(Instruction *I) {
if (getReplacement(I)) if (getReplacement(I))

View File

@ -210,11 +210,7 @@ static Constant *getInitializer(Constant *C) {
Constant *Evaluator::ComputeLoadResult(Constant *P) { Constant *Evaluator::ComputeLoadResult(Constant *P) {
// If this memory location has been recently stored, use the stored value: it // If this memory location has been recently stored, use the stored value: it
// is the most up-to-date. // is the most up-to-date.
auto findMemLoc = [this](Constant *Ptr) { auto findMemLoc = [this](Constant *Ptr) { return MutatedMemory.lookup(Ptr); };
DenseMap<Constant *, Constant *>::const_iterator I =
MutatedMemory.find(Ptr);
return I != MutatedMemory.end() ? I->second : nullptr;
};
if (Constant *Val = findMemLoc(P)) if (Constant *Val = findMemLoc(P))
return Val; return Val;

View File

@ -64,8 +64,7 @@ bool SSAUpdater::HasValueForBlock(BasicBlock *BB) const {
} }
Value *SSAUpdater::FindValueForBlock(BasicBlock *BB) const { Value *SSAUpdater::FindValueForBlock(BasicBlock *BB) const {
AvailableValsTy::iterator AVI = getAvailableVals(AV).find(BB); return getAvailableVals(AV).lookup(BB);
return (AVI != getAvailableVals(AV).end()) ? AVI->second : nullptr;
} }
void SSAUpdater::AddAvailableValue(BasicBlock *BB, Value *V) { void SSAUpdater::AddAvailableValue(BasicBlock *BB, Value *V) {

View File

@ -1840,18 +1840,10 @@ private:
} }
#endif #endif
TreeEntry *getTreeEntry(Value *V) { TreeEntry *getTreeEntry(Value *V) { return ScalarToTreeEntry.lookup(V); }
auto I = ScalarToTreeEntry.find(V);
if (I != ScalarToTreeEntry.end())
return I->second;
return nullptr;
}
const TreeEntry *getTreeEntry(Value *V) const { const TreeEntry *getTreeEntry(Value *V) const {
auto I = ScalarToTreeEntry.find(V); return ScalarToTreeEntry.lookup(V);
if (I != ScalarToTreeEntry.end())
return I->second;
return nullptr;
} }
/// Maps a specific scalar to its tree entry. /// Maps a specific scalar to its tree entry.

View File

@ -2013,9 +2013,7 @@ public:
/// \returns nullptr if doesn't have such group. /// \returns nullptr if doesn't have such group.
InterleaveGroup<VPInstruction> * InterleaveGroup<VPInstruction> *
getInterleaveGroup(VPInstruction *Instr) const { getInterleaveGroup(VPInstruction *Instr) const {
if (InterleaveGroupMap.count(Instr)) return InterleaveGroupMap.lookup(Instr);
return InterleaveGroupMap.find(Instr)->second;
return nullptr;
} }
}; };