[llvm] [Coroutines] Avoid repeated hash lookups (NFC) (PR #111617)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 8 19:20:44 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111617

None

>From 52796a62761708d7559906eef516e5e764ea5384 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 8 Oct 2024 07:38:14 -0700
Subject: [PATCH] [Coroutines] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 91530503a7e1ed..2b43b7a5d027d1 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -797,8 +797,8 @@ static void buildFrameDebugInfo(Function &F, coro::Shape &Shape,
     AlignInBits = OffsetCache[Index].first * 8;
     OffsetInBits = OffsetCache[Index].second * 8;
 
-    if (NameCache.contains(Index)) {
-      Name = NameCache[Index].str();
+    if (auto It = NameCache.find(Index); It != NameCache.end()) {
+      Name = It->second.str();
       DITy = TyCache[Index];
     } else {
       DITy = solveDIType(DBuilder, Ty, Layout, FrameDITy, LineNum, DITypeCache);



More information about the llvm-commits mailing list