[llvm] c963892 - [llvm] Use DenseMapBase::lookup (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 09:02:43 PDT 2023


Author: Kazu Hirata
Date: 2023-06-10T09:02:25-07:00
New Revision: c963892a451fea716dcc7030552a45deafcdbe58

URL: https://github.com/llvm/llvm-project/commit/c963892a451fea716dcc7030552a45deafcdbe58
DIFF: https://github.com/llvm/llvm-project/commit/c963892a451fea716dcc7030552a45deafcdbe58.diff

LOG: [llvm] Use DenseMapBase::lookup (NFC)

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
    llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
    llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index ea9a2d7e5e397..f23ab6354f60a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3596,11 +3596,9 @@ dwarf::Form DwarfDebug::getDwarfSectionOffsetForm() const {
 }
 
 const MCSymbol *DwarfDebug::getSectionLabel(const MCSection *S) {
-  auto I = SectionLabels.find(S);
-  if (I == SectionLabels.end())
-    return nullptr;
-  return I->second;
+  return SectionLabels.lookup(S);
 }
+
 void DwarfDebug::insertSectionLabel(const MCSymbol *S) {
   if (SectionLabels.insert(std::make_pair(&S->getSection(), S)).second)
     if (useSplitDwarf() || getDwarfVersion() >= 5)

diff  --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 9969206559f76..110f30b507583 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -4055,10 +4055,7 @@ template <> class SSAUpdaterTraits<LDVSSAUpdater> {
   /// ValueIsPHI - Check if the instruction that defines the specified value
   /// is a PHI instruction.
   static LDVSSAPhi *ValueIsPHI(BlockValueNum Val, LDVSSAUpdater *Updater) {
-    auto PHIIt = Updater->PHIs.find(Val);
-    if (PHIIt == Updater->PHIs.end())
-      return nullptr;
-    return PHIIt->second;
+    return Updater->PHIs.lookup(Val);
   }
 
   /// ValueIsNewPHI - Like ValueIsPHI but also check if the PHI has no source

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index e1c1d498f5aed..bd69838a50829 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -91,10 +91,7 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
   }
 
   Block *getGraphBlock(ELFSectionIndex SecIndex) {
-    auto I = GraphBlocks.find(SecIndex);
-    if (I == GraphBlocks.end())
-      return nullptr;
-    return I->second;
+    return GraphBlocks.lookup(SecIndex);
   }
 
   void setGraphSymbol(ELFSymbolIndex SymIndex, Symbol &Sym) {
@@ -103,10 +100,7 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
   }
 
   Symbol *getGraphSymbol(ELFSymbolIndex SymIndex) {
-    auto I = GraphSymbols.find(SymIndex);
-    if (I == GraphSymbols.end())
-      return nullptr;
-    return I->second;
+    return GraphSymbols.lookup(SymIndex);
   }
 
   Expected<std::pair<Linkage, Scope>>

diff  --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index 6c9cde7357e7a..db87b3d57804c 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -706,22 +706,14 @@ CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForInst(
   if (Node)
     return Node;
 
-  auto NonAllocCallNode = NonAllocationCallToContextNodeMap.find(C);
-  if (NonAllocCallNode != NonAllocationCallToContextNodeMap.end()) {
-    return NonAllocCallNode->second;
-  }
-  return nullptr;
+  return NonAllocationCallToContextNodeMap.lookup(C);
 }
 
 template <typename DerivedCCG, typename FuncTy, typename CallTy>
 typename CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode *
 CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::getNodeForAlloc(
     const CallInfo &C) {
-  auto AllocCallNode = AllocationCallToContextNodeMap.find(C);
-  if (AllocCallNode != AllocationCallToContextNodeMap.end()) {
-    return AllocCallNode->second;
-  }
-  return nullptr;
+  return AllocationCallToContextNodeMap.lookup(C);
 }
 
 template <typename DerivedCCG, typename FuncTy, typename CallTy>

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 055da0347d068..72cf16fc3337c 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2643,10 +2643,7 @@ class VPlan {
   }
 
   VPValue *getSCEVExpansion(const SCEV *S) const {
-    auto I = SCEVToExpansion.find(S);
-    if (I == SCEVToExpansion.end())
-      return nullptr;
-    return I->second;
+    return SCEVToExpansion.lookup(S);
   }
 
   void addSCEVExpansion(const SCEV *S, VPValue *V) {


        


More information about the llvm-commits mailing list