[llvm] [IR] Avoid repeated hash lookups (NFC) (PR #138430)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat May 3 18:03:28 PDT 2025


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

None

>From a1f022416bad464a2ec8b27b24710c4226502420 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 3 May 2025 17:54:50 -0700
Subject: [PATCH] [IR] Avoid repeated hash lookups (NFC)

---
 llvm/lib/IR/DroppedVariableStats.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/IR/DroppedVariableStats.cpp b/llvm/lib/IR/DroppedVariableStats.cpp
index 9e221bf585f1a..b8c0dd6e7b1dc 100644
--- a/llvm/lib/IR/DroppedVariableStats.cpp
+++ b/llvm/lib/IR/DroppedVariableStats.cpp
@@ -117,8 +117,7 @@ void DroppedVariableStats::removeVarFromAllSets(VarID Var, const Function *F) {
 bool DroppedVariableStats::isScopeChildOfOrEqualTo(const DIScope *Scope,
                                                    const DIScope *DbgValScope) {
   while (Scope != nullptr) {
-    if (VisitedScope.find(Scope) == VisitedScope.end()) {
-      VisitedScope.insert(Scope);
+    if (VisitedScope.insert(Scope).second) {
       if (Scope == DbgValScope) {
         VisitedScope.clear();
         return true;



More information about the llvm-commits mailing list