[llvm] [Analysis] Simplify code with DenseMap::operator[] (NFC) (PR #111331)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 6 19:48:37 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111331
None
>From a063af77df1cc8f5c8e57a10de0b8731155f55c9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 6 Oct 2024 19:41:23 -0700
Subject: [PATCH] [Analysis] Simplify code with DenseMap::operator[] (NFC)
---
llvm/lib/Analysis/BasicAliasAnalysis.cpp | 6 ++----
llvm/lib/Analysis/LoopAccessAnalysis.cpp | 6 ++----
llvm/lib/Analysis/ScalarEvolution.cpp | 3 +--
3 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index f471c0db11d3ef..1dcdad01f4c809 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -219,10 +219,8 @@ bool EarliestEscapeInfo::isNotCapturedBefore(const Value *Object,
Instruction *EarliestCapture = FindEarliestCapture(
Object, *const_cast<Function *>(DT.getRoot()->getParent()),
/*ReturnCaptures=*/false, /*StoreCaptures=*/true, DT);
- if (EarliestCapture) {
- auto Ins = Inst2Obj.insert({EarliestCapture, {}});
- Ins.first->second.push_back(Object);
- }
+ if (EarliestCapture)
+ Inst2Obj[EarliestCapture].push_back(Object);
Iter.first->second = EarliestCapture;
}
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index fe00ea0097a43a..d35bf6818d4379 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -512,10 +512,8 @@ void RuntimePointerChecking::groupChecks(
unsigned TotalComparisons = 0;
DenseMap<Value *, SmallVector<unsigned>> PositionMap;
- for (unsigned Index = 0; Index < Pointers.size(); ++Index) {
- auto [It, _] = PositionMap.insert({Pointers[Index].PointerValue, {}});
- It->second.push_back(Index);
- }
+ for (unsigned Index = 0; Index < Pointers.size(); ++Index)
+ PositionMap[Pointers[Index].PointerValue].push_back(Index);
// We need to keep track of what pointers we've already seen so we
// don't process them twice.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c939270ed39a65..3d890f05c8ca21 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -1564,8 +1564,7 @@ static void insertFoldCacheEntry(
UserIDs.pop_back();
I.first->second = S;
}
- auto R = FoldCacheUser.insert({S, {}});
- R.first->second.push_back(ID);
+ FoldCacheUser[S].push_back(ID);
}
const SCEV *
More information about the llvm-commits
mailing list