[llvm] [SSAUpdater] Use DenseMap::operator[] (NFC) (PR #107179)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 20:26:52 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107179

I'm planning to deprecate DenseMap::FindAndConstruct in favor of
DenseMap::operator[].  I thought about renaming the variable to
PredInfo, but the name is taken, so I am leaving the name as is.


>From 3d57ca8edc6028cf943c897f521e1abafe8d2f4f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 3 Sep 2024 20:13:51 -0700
Subject: [PATCH] [SSAUpdater] Use DenseMap::operator[] (NFC)

I'm planning to deprecate DenseMap::FindAndConstruct in favor of
DenseMap::operator[].  I thought about renaming the variable to
PredInfo, but the name is taken, so I am leaving the name as is.
---
 llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
index 010d6b0de9f6af..746926e5bee331 100644
--- a/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
+++ b/llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h
@@ -139,17 +139,16 @@ class SSAUpdaterImpl {
       for (unsigned p = 0; p != Info->NumPreds; ++p) {
         BlkT *Pred = Preds[p];
         // Check if BBMap already has a BBInfo for the predecessor block.
-        typename BBMapTy::value_type &BBMapBucket =
-          BBMap.FindAndConstruct(Pred);
-        if (BBMapBucket.second) {
-          Info->Preds[p] = BBMapBucket.second;
+        BBInfo *&BBMapBucket = BBMap[Pred];
+        if (BBMapBucket) {
+          Info->Preds[p] = BBMapBucket;
           continue;
         }
 
         // Create a new BBInfo for the predecessor.
         ValT PredVal = AvailableVals->lookup(Pred);
         BBInfo *PredInfo = new (Allocator) BBInfo(Pred, PredVal);
-        BBMapBucket.second = PredInfo;
+        BBMapBucket = PredInfo;
         Info->Preds[p] = PredInfo;
 
         if (PredInfo->AvailableVal) {



More information about the llvm-commits mailing list