[llvm] [AsmPrinter] Avoid repeated hash lookups (NFC) (PR #125814)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 23:19:34 PST 2025


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

None

>From 992212e9a2588fae61d92d5ad9a71427bb994951 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 4 Feb 2025 09:52:21 -0800
Subject: [PATCH] [AsmPrinter] Avoid repeated hash lookups (NFC)

---
 llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 6cf05fda544ed3d..ddf0275ddfe6a47 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1757,8 +1757,11 @@ void DwarfCompileUnit::createBaseTypeDIEs() {
 DIE *DwarfCompileUnit::getLexicalBlockDIE(const DILexicalBlock *LB) {
   // Assume if there is an abstract tree all the DIEs are already emitted.
   bool isAbstract = getAbstractScopeDIEs().count(LB->getSubprogram());
-  if (isAbstract && getAbstractScopeDIEs().count(LB))
-    return getAbstractScopeDIEs()[LB];
+  if (isAbstract) {
+    auto &DIEs = getAbstractScopeDIEs();
+    if (auto It = DIEs.find(LB); It != DIEs.end())
+      return It->second;
+  }
   assert(!isAbstract && "Missed lexical block DIE in abstract tree!");
 
   // Return a concrete DIE if it exists or nullptr otherwise.



More information about the llvm-commits mailing list