Skip to content

Commit 825a0aa

Browse files
kazutakahiratacyndyishida
authored andcommitted
[llvm] Use DenseMap::lookup (NFC)
(cherry picked from commit 3c03a15)
1 parent 8dba3b1 commit 825a0aa

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

llvm/include/llvm/ADT/GenericCycleImpl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,7 @@ void GenericCycleInfo<ContextT>::compute(FunctionT &F) {
370370
template <typename ContextT>
371371
auto GenericCycleInfo<ContextT>::getCycle(const BlockT *Block) const
372372
-> CycleT * {
373-
auto MapIt = BlockMap.find(Block);
374-
if (MapIt != BlockMap.end())
375-
return MapIt->second;
376-
return nullptr;
373+
return BlockMap.lookup(Block);
377374
}
378375

379376
/// \brief get the depth for the cycle which containing a given block.

llvm/lib/TextAPI/SymbolSet.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,5 @@ Symbol *SymbolSet::addGlobal(SymbolKind Kind, StringRef Name, SymbolFlags Flags,
2929
}
3030

3131
const Symbol *SymbolSet::findSymbol(SymbolKind Kind, StringRef Name) const {
32-
auto It = Symbols.find({Kind, Name});
33-
if (It != Symbols.end())
34-
return It->second;
35-
return nullptr;
32+
return Symbols.lookup({Kind, Name});
3633
}

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ static Cost estimateBasicBlocks(SmallVectorImpl<BasicBlock *> &WorkList,
147147
static Constant *findConstantFor(Value *V, ConstMap &KnownConstants) {
148148
if (auto *C = dyn_cast<Constant>(V))
149149
return C;
150-
if (auto It = KnownConstants.find(V); It != KnownConstants.end())
151-
return It->second;
152-
return nullptr;
150+
return KnownConstants.lookup(V);
153151
}
154152

155153
Cost InstCostVisitor::getUserBonus(Instruction *User, Value *Use, Constant *C) {

0 commit comments

Comments
 (0)