[clang] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (PR #107158)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 15:11:44 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107158
I'm planning to deprecate DenseMap::FindAndConstruct in favor of
DenseMap::operator[].
>From e64e76f869af9d37625979dca68e1ee4f76b5bbc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 3 Sep 2024 15:00:28 -0700
Subject: [PATCH] [CGOpenMPRuntime] Use DenseMap::operator[] (NFC)
I'm planning to deprecate DenseMap::FindAndConstruct in favor of
DenseMap::operator[].
---
clang/lib/CodeGen/CGOpenMPRuntime.cpp | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 34120486996fb1..23b977be816025 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1149,10 +1149,8 @@ void CGOpenMPRuntime::emitUserDefinedReduction(
/*IsCombiner=*/false);
}
UDRMap.try_emplace(D, Combiner, Initializer);
- if (CGF) {
- auto &Decls = FunctionUDRMap.FindAndConstruct(CGF->CurFn);
- Decls.second.push_back(D);
- }
+ if (CGF)
+ FunctionUDRMap[CGF->CurFn].push_back(D);
}
std::pair<llvm::Function *, llvm::Function *>
@@ -1432,10 +1430,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
ThreadID = CGF.EmitLoadOfScalar(LVal, Loc);
// If value loaded in entry block, cache it and use it everywhere in
// function.
- if (CGF.Builder.GetInsertBlock() == TopBlock) {
- auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
- Elem.second.ThreadID = ThreadID;
- }
+ if (CGF.Builder.GetInsertBlock() == TopBlock)
+ OpenMPLocThreadIDMap[CGF.CurFn].ThreadID = ThreadID;
return ThreadID;
}
}
@@ -8640,8 +8636,7 @@ class MappableExprsHandler {
const MapData &BaseData = CI == CE ? L : L1;
OMPClauseMappableExprCommon::MappableExprComponentListRef SubData =
SI == SE ? Components : Components1;
- auto &OverlappedElements = OverlappedData.FindAndConstruct(&BaseData);
- OverlappedElements.getSecond().push_back(SubData);
+ OverlappedData[&BaseData].push_back(SubData);
}
}
}
@@ -9316,10 +9311,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
MapperCGF.EmitBlock(DoneBB, /*IsFinished=*/true);
MapperCGF.FinishFunction();
UDMMap.try_emplace(D, Fn);
- if (CGF) {
- auto &Decls = FunctionUDMMap.FindAndConstruct(CGF->CurFn);
- Decls.second.push_back(D);
- }
+ if (CGF)
+ FunctionUDMMap[CGF->CurFn].push_back(D);
}
/// Emit the array initialization or deletion portion for user-defined mapper
More information about the cfe-commits
mailing list