Skip to content

Commit ecccc6a

Browse files
[Coroutines] Avoid repeated hash lookps (NFC) (#110076)
1 parent f4b1335 commit ecccc6a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/lib/Transforms/Coroutines/SpillUtils.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,11 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
397397
if (!IsOffsetKnown) {
398398
AliasOffetMap[&I].reset();
399399
} else {
400-
auto Itr = AliasOffetMap.find(&I);
401-
if (Itr == AliasOffetMap.end()) {
402-
AliasOffetMap[&I] = Offset;
403-
} else if (Itr->second && *Itr->second != Offset) {
400+
auto [Itr, Inserted] = AliasOffetMap.try_emplace(&I, Offset);
401+
if (!Inserted && Itr->second && *Itr->second != Offset) {
404402
// If we have seen two different possible values for this alias, we set
405403
// it to empty.
406-
AliasOffetMap[&I].reset();
404+
Itr->second.reset();
407405
}
408406
}
409407
}

0 commit comments

Comments
 (0)