diff --git a/include/llvm/Analysis/RegionInfoImpl.h b/include/llvm/Analysis/RegionInfoImpl.h
index bbd3dd5dc0e..d28aee72dda 100644
--- a/include/llvm/Analysis/RegionInfoImpl.h
+++ b/include/llvm/Analysis/RegionInfoImpl.h
@@ -815,8 +815,7 @@ void RegionInfoBase
::verifyAnalysis() const {
// Region pass manager support.
template
typename Tr::RegionT *RegionInfoBase::getRegionFor(BlockT *BB) const {
- typename BBtoRegionMap::const_iterator I = BBtoRegion.find(BB);
- return I != BBtoRegion.end() ? I->second : nullptr;
+ return BBtoRegion.lookup(BB);
}
template
diff --git a/include/llvm/Analysis/VectorUtils.h b/include/llvm/Analysis/VectorUtils.h
index c570bf25e92..d8fb970a9f7 100644
--- a/include/llvm/Analysis/VectorUtils.h
+++ b/include/llvm/Analysis/VectorUtils.h
@@ -655,11 +655,7 @@ public:
/// \returns nullptr if contains no such member.
InstTy *getMember(uint32_t Index) const {
int32_t Key = SmallestKey + Index;
- auto Member = Members.find(Key);
- if (Member == Members.end())
- return nullptr;
-
- return Member->second;
+ return Members.lookup(Key);
}
/// Get the index for the given member. Unlike the key in the member
@@ -777,9 +773,7 @@ public:
/// \returns nullptr if doesn't have such group.
InterleaveGroup *
getInterleaveGroup(const Instruction *Instr) const {
- if (InterleaveGroupMap.count(Instr))
- return InterleaveGroupMap.find(Instr)->second;
- return nullptr;
+ return InterleaveGroupMap.lookup(Instr);
}
iterator_range *>>
diff --git a/lib/IR/PassRegistry.cpp b/lib/IR/PassRegistry.cpp
index 0572c4fe523..94f607afec4 100644
--- a/lib/IR/PassRegistry.cpp
+++ b/lib/IR/PassRegistry.cpp
@@ -40,14 +40,12 @@ PassRegistry::~PassRegistry() = default;
const PassInfo *PassRegistry::getPassInfo(const void *TI) const {
sys::SmartScopedReader Guard(Lock);
- MapType::const_iterator I = PassInfoMap.find(TI);
- return I != PassInfoMap.end() ? I->second : nullptr;
+ return PassInfoMap.lookup(TI);
}
const PassInfo *PassRegistry::getPassInfo(StringRef Arg) const {
sys::SmartScopedReader Guard(Lock);
- StringMapType::const_iterator I = PassInfoStringMap.find(Arg);
- return I != PassInfoStringMap.end() ? I->second : nullptr;
+ return PassInfoStringMap.lookup(Arg);
}
//===----------------------------------------------------------------------===//
diff --git a/lib/IR/SafepointIRVerifier.cpp b/lib/IR/SafepointIRVerifier.cpp
index 6bf7caa50a1..8ed31b6668e 100644
--- a/lib/IR/SafepointIRVerifier.cpp
+++ b/lib/IR/SafepointIRVerifier.cpp
@@ -561,8 +561,7 @@ GCPtrTracker::GCPtrTracker(const Function &F, const DominatorTree &DT,
}
BasicBlockState *GCPtrTracker::getBasicBlockState(const BasicBlock *BB) {
- auto it = BlockMap.find(BB);
- return it != BlockMap.end() ? it->second : nullptr;
+ return BlockMap.lookup(BB);
}
const BasicBlockState *GCPtrTracker::getBasicBlockState(