[llvm] [Coroutines] Avoid repeated hash lookps (NFC) (PR #110076)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 20:21:56 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-coroutines
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/110076.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Coroutines/SpillUtils.cpp (+3-5)
``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
index f213ac1c8d7d57..96b5c8440e5f9a 100644
--- a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
+++ b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
@@ -397,13 +397,11 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
if (!IsOffsetKnown) {
AliasOffetMap[&I].reset();
} else {
- auto Itr = AliasOffetMap.find(&I);
- if (Itr == AliasOffetMap.end()) {
- AliasOffetMap[&I] = Offset;
- } else if (Itr->second && *Itr->second != Offset) {
+ auto [Itr, Inserted] = AliasOffetMap.try_emplace(&I, Offset);
+ if (!Inserted && Itr->second && *Itr->second != Offset) {
// If we have seen two different possible values for this alias, we set
// it to empty.
- AliasOffetMap[&I].reset();
+ Itr->second.reset();
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110076
More information about the llvm-commits
mailing list