[llvm] 38cc5bc - [llvm] Use DenseMap::contains (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 00:10:01 PDT 2023


Author: Kazu Hirata
Date: 2023-08-23T00:09:54-07:00
New Revision: 38cc5bcdf5bc99fbbcf3454b429e80b7d98037fe

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

LOG: [llvm] Use DenseMap::contains (NFC)

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
    llvm/include/llvm/Analysis/DependenceGraphBuilder.h
    llvm/include/llvm/Analysis/EHUtils.h
    llvm/include/llvm/Analysis/VectorUtils.h
    llvm/include/llvm/Transforms/Utils/SampleProfileInference.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 9d96748874a04b..a75f65c0dfc17e 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1580,7 +1580,7 @@ void BlockFrequencyInfoImpl<BT>::initTransitionProbabilities(
     SmallPtrSet<const BlockT *, 2> UniqueSuccs;
     for (const auto SI : children<const BlockT *>(BB)) {
       // Ignore cold blocks
-      if (BlockIndex.find(SI) == BlockIndex.end())
+      if (!BlockIndex.contains(SI))
         continue;
       // Ignore parallel edges between BB and SI blocks
       if (!UniqueSuccs.insert(SI).second)

diff  --git a/llvm/include/llvm/Analysis/DependenceGraphBuilder.h b/llvm/include/llvm/Analysis/DependenceGraphBuilder.h
index f490f20e7c19aa..98f1764e14b0e9 100644
--- a/llvm/include/llvm/Analysis/DependenceGraphBuilder.h
+++ b/llvm/include/llvm/Analysis/DependenceGraphBuilder.h
@@ -163,8 +163,7 @@ template <class GraphType> class AbstractDependenceGraphBuilder {
 
   /// Given a node \p N return its associated ordinal number.
   size_t getOrdinal(NodeType &N) {
-    assert(NodeOrdinalMap.find(&N) != NodeOrdinalMap.end() &&
-           "No ordinal computed for this node.");
+    assert(NodeOrdinalMap.contains(&N) && "No ordinal computed for this node.");
     return NodeOrdinalMap[&N];
   }
 

diff  --git a/llvm/include/llvm/Analysis/EHUtils.h b/llvm/include/llvm/Analysis/EHUtils.h
index 728ab53c89bcfa..f2ff6cbd2e9036 100644
--- a/llvm/include/llvm/Analysis/EHUtils.h
+++ b/llvm/include/llvm/Analysis/EHUtils.h
@@ -24,7 +24,7 @@ static void computeEHOnlyBlocks(FunctionT &F, DenseSet<BlockT *> &EHBlocks) {
   DenseMap<BlockT *, Status> Statuses;
 
   auto GetStatus = [&](BlockT *BB) {
-    if (Statuses.find(BB) != Statuses.end())
+    if (Statuses.contains(BB))
       return Statuses[BB];
     else
       return Unknown;

diff  --git a/llvm/include/llvm/Analysis/VectorUtils.h b/llvm/include/llvm/Analysis/VectorUtils.h
index ad69f5711abd48..98ae6e4a02158d 100644
--- a/llvm/include/llvm/Analysis/VectorUtils.h
+++ b/llvm/include/llvm/Analysis/VectorUtils.h
@@ -670,7 +670,7 @@ template <typename InstTy> class InterleaveGroup {
       return false;
 
     // Skip if there is already a member with the same index.
-    if (Members.find(Key) != Members.end())
+    if (Members.contains(Key))
       return false;
 
     if (Key > LargestKey) {

diff  --git a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
index e9bc3d18bdcbf8..b69468ee7e489f 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileInference.h
@@ -247,7 +247,7 @@ FlowFunction SampleProfileInference<BT>::createFlowFunction(
   // Create FlowBlocks
   for (const auto *BB : BasicBlocks) {
     FlowBlock Block;
-    if (SampleBlockWeights.find(BB) != SampleBlockWeights.end()) {
+    if (SampleBlockWeights.contains(BB)) {
       Block.HasUnknownWeight = false;
       Block.Weight = SampleBlockWeights[BB];
     } else {


        


More information about the llvm-commits mailing list