Skip to content

Commit

Permalink
Use DenseMap::lookup (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Dec 18, 2021
1 parent fa12606 commit fee5771
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions clang/lib/AST/ParentMap.cpp
Expand Up @@ -133,8 +133,7 @@ void ParentMap::setParent(const Stmt *S, const Stmt *Parent) {

Stmt* ParentMap::getParent(Stmt* S) const {
MapTy* M = (MapTy*) Impl;
MapTy::iterator I = M->find(S);
return I == M->end() ? nullptr : I->second;
return M->lookup(S);
}

Stmt *ParentMap::getParentIgnoreParens(Stmt *S) const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
Expand Up @@ -83,7 +83,7 @@ void DAGTypeLegalizer::PerformExpensiveChecks() {
SDValue Res(&Node, i);
bool Failed = false;
// Don't create a value in map.
auto ResId = (ValueToIdMap.count(Res)) ? ValueToIdMap[Res] : 0;
auto ResId = ValueToIdMap.lookup(Res);

unsigned Mapped = 0;
if (ResId && (ReplacedValues.find(ResId) != ReplacedValues.end())) {
Expand Down
8 changes: 3 additions & 5 deletions llvm/lib/Transforms/IPO/SampleProfile.cpp
Expand Up @@ -1159,11 +1159,9 @@ bool SampleProfileLoader::inlineHotFunctions(
}
for (CallBase *I : CIS) {
Function *CalledFunction = I->getCalledFunction();
InlineCandidate Candidate = {
I,
LocalNotInlinedCallSites.count(I) ? LocalNotInlinedCallSites[I]
: nullptr,
0 /* dummy count */, 1.0 /* dummy distribution factor */};
InlineCandidate Candidate = {I, LocalNotInlinedCallSites.lookup(I),
0 /* dummy count */,
1.0 /* dummy distribution factor */};
// Do not inline recursive calls.
if (CalledFunction == &F)
continue;
Expand Down

0 comments on commit fee5771

Please sign in to comment.