Skip to content

Commit d1620c1

Browse files
[Scalar] Simplify code with *Map::operator[] (NFC) (llvm#112120)
1 parent 1641745 commit d1620c1

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ static void runImpl(Function &F, const TargetLibraryInfo &TLI) {
5252
for (Instruction &I : instructions(F)) {
5353
if (!I.hasMetadata(LLVMContext::MD_annotation))
5454
continue;
55-
auto Iter = DebugLoc2Annotated.insert({I.getDebugLoc().getAsMDNode(), {}});
56-
Iter.first->second.push_back(&I);
55+
DebugLoc2Annotated[I.getDebugLoc().getAsMDNode()].push_back(&I);
5756

5857
for (const MDOperand &Op :
5958
I.getMetadata(LLVMContext::MD_annotation)->operands()) {
@@ -62,8 +61,7 @@ static void runImpl(Function &F, const TargetLibraryInfo &TLI) {
6261
? cast<MDString>(Op.get())->getString()
6362
: cast<MDString>(cast<MDTuple>(Op.get())->getOperand(0).get())
6463
->getString();
65-
auto Iter = Mapping.insert({AnnotationStr, 0});
66-
Iter.first->second++;
64+
Mapping[AnnotationStr]++;
6765
}
6866
}
6967

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,8 +2486,7 @@ class LowerMatrixIntrinsics {
24862486
if (!ExprsInSubprogram.count(V))
24872487
return;
24882488

2489-
auto I = Shared.insert({V, {}});
2490-
I.first->second.insert(Leaf);
2489+
Shared[V].insert(Leaf);
24912490

24922491
for (Value *Op : cast<Instruction>(V)->operand_values())
24932492
collectSharedInfo(Leaf, Op, ExprsInSubprogram, Shared);
@@ -2538,14 +2537,12 @@ class LowerMatrixIntrinsics {
25382537
auto *I = cast<Instruction>(KV.first);
25392538
DILocation *Context = I->getDebugLoc();
25402539
while (Context) {
2541-
auto I =
2542-
Subprog2Exprs.insert({getSubprogram(Context->getScope()), {}});
2543-
I.first->second.push_back(KV.first);
2540+
Subprog2Exprs[getSubprogram(Context->getScope())].push_back(
2541+
KV.first);
25442542
Context = DebugLoc(Context).getInlinedAt();
25452543
}
25462544
} else {
2547-
auto I = Subprog2Exprs.insert({nullptr, {}});
2548-
I.first->second.push_back(KV.first);
2545+
Subprog2Exprs[nullptr].push_back(KV.first);
25492546
}
25502547
}
25512548
for (auto &KV : Subprog2Exprs) {

0 commit comments

Comments
 (0)