Skip to content

Commit 8133d47

Browse files
[CGOpenMPRuntime] Use DenseMap::operator[] (NFC) (llvm#107185)
I'm planning to deprecate DenseMap::FindAndConstruct in favor of DenseMap::operator[].
1 parent 331f822 commit 8133d47

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,25 +1327,24 @@ llvm::Function *CGOpenMPRuntime::emitTaskOutlinedFunction(
13271327

13281328
void CGOpenMPRuntime::setLocThreadIdInsertPt(CodeGenFunction &CGF,
13291329
bool AtCurrentPoint) {
1330-
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
1331-
assert(!Elem.second.ServiceInsertPt && "Insert point is set already.");
1330+
auto &Elem = OpenMPLocThreadIDMap[CGF.CurFn];
1331+
assert(!Elem.ServiceInsertPt && "Insert point is set already.");
13321332

13331333
llvm::Value *Undef = llvm::UndefValue::get(CGF.Int32Ty);
13341334
if (AtCurrentPoint) {
1335-
Elem.second.ServiceInsertPt = new llvm::BitCastInst(
1336-
Undef, CGF.Int32Ty, "svcpt", CGF.Builder.GetInsertBlock());
1335+
Elem.ServiceInsertPt = new llvm::BitCastInst(Undef, CGF.Int32Ty, "svcpt",
1336+
CGF.Builder.GetInsertBlock());
13371337
} else {
1338-
Elem.second.ServiceInsertPt =
1339-
new llvm::BitCastInst(Undef, CGF.Int32Ty, "svcpt");
1340-
Elem.second.ServiceInsertPt->insertAfter(CGF.AllocaInsertPt);
1338+
Elem.ServiceInsertPt = new llvm::BitCastInst(Undef, CGF.Int32Ty, "svcpt");
1339+
Elem.ServiceInsertPt->insertAfter(CGF.AllocaInsertPt);
13411340
}
13421341
}
13431342

13441343
void CGOpenMPRuntime::clearLocThreadIdInsertPt(CodeGenFunction &CGF) {
1345-
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
1346-
if (Elem.second.ServiceInsertPt) {
1347-
llvm::Instruction *Ptr = Elem.second.ServiceInsertPt;
1348-
Elem.second.ServiceInsertPt = nullptr;
1344+
auto &Elem = OpenMPLocThreadIDMap[CGF.CurFn];
1345+
if (Elem.ServiceInsertPt) {
1346+
llvm::Instruction *Ptr = Elem.ServiceInsertPt;
1347+
Elem.ServiceInsertPt = nullptr;
13491348
Ptr->eraseFromParent();
13501349
}
13511350
}
@@ -1441,18 +1440,18 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
14411440
// kmpc_global_thread_num(ident_t *loc).
14421441
// Generate thread id value and cache this value for use across the
14431442
// function.
1444-
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
1445-
if (!Elem.second.ServiceInsertPt)
1443+
auto &Elem = OpenMPLocThreadIDMap[CGF.CurFn];
1444+
if (!Elem.ServiceInsertPt)
14461445
setLocThreadIdInsertPt(CGF);
14471446
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
1448-
CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
1447+
CGF.Builder.SetInsertPoint(Elem.ServiceInsertPt);
14491448
auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
14501449
llvm::CallInst *Call = CGF.Builder.CreateCall(
14511450
OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
14521451
OMPRTL___kmpc_global_thread_num),
14531452
emitUpdateLocation(CGF, Loc));
14541453
Call->setCallingConv(CGF.getRuntimeCC());
1455-
Elem.second.ThreadID = Call;
1454+
Elem.ThreadID = Call;
14561455
return Call;
14571456
}
14581457

0 commit comments

Comments
 (0)