aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-03-16 09:30:05 -0700
committerGitHub <noreply@github.com>2025-03-16 09:30:05 -0700
commit1bc2108c49f413052cee798906c9d57dc18e1a1e (patch)
treeb731adeef910ab8d86dd55a7d7db40e2023ec1a7 /llvm/lib/Transforms/IPO/FunctionAttrs.cpp
parent48ecec20a2048689e53007ce4b929a7d6a9a3b17 (diff)
downloadllvm-1bc2108c49f413052cee798906c9d57dc18e1a1e.zip
llvm-1bc2108c49f413052cee798906c9d57dc18e1a1e.tar.gz
llvm-1bc2108c49f413052cee798906c9d57dc18e1a1e.tar.bz2
[Transforms] Avoid repeated hash lookups (NFC) (#131497)
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 1fca1b5..f70686b 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -319,8 +319,8 @@ static FunctionSummary *calculatePrevailingSummary(
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing) {
- if (auto It = CachedPrevailingSummary.find(VI);
- It != CachedPrevailingSummary.end())
+ auto [It, Inserted] = CachedPrevailingSummary.try_emplace(VI);
+ if (!Inserted)
return It->second;
/// At this point, prevailing symbols have been resolved. The following leads
@@ -363,7 +363,6 @@ static FunctionSummary *calculatePrevailingSummary(
/// future this can be revisited.
/// 5. Otherwise, go conservative.
- CachedPrevailingSummary[VI] = nullptr;
FunctionSummary *Local = nullptr;
FunctionSummary *Prevailing = nullptr;
@@ -764,12 +763,12 @@ ArgumentUsesSummary collectArgumentUsesPerBlock(Argument &A, Function &F) {
auto UpdateUseInfo = [&Result](Instruction *I, ArgumentAccessInfo Info) {
auto *BB = I->getParent();
auto &BBInfo = Result.UsesPerBlock[BB];
- bool AlreadyVisitedInst = BBInfo.Insts.contains(I);
- auto &IInfo = BBInfo.Insts[I];
+ auto [It, Inserted] = BBInfo.Insts.try_emplace(I);
+ auto &IInfo = It->second;
// Instructions that have more than one use of the argument are considered
// as clobbers.
- if (AlreadyVisitedInst) {
+ if (!Inserted) {
IInfo = {ArgumentAccessInfo::AccessType::Unknown, {}};
BBInfo.HasUnknownAccess = true;
return false;