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

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 28 10:44:18 PDT 2024


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

None

>From be9acc5f879a53e3e48921d9c7f7706b778af2aa Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 27 Sep 2024 08:32:27 -0700
Subject: [PATCH] [AsmPrinter] Avoid repeated hash lookups (NFC)

---
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 5cba2cbc241e40..a692e7aef62684 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3406,10 +3406,8 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
     OS.emitInt32(getCompleteTypeIndex(DIGV->getType()).getIndex());
     OS.AddComment("DataOffset");
 
-    uint64_t Offset = 0;
-    if (CVGlobalVariableOffsets.contains(DIGV))
-      // Use the offset seen while collecting info on globals.
-      Offset = CVGlobalVariableOffsets[DIGV];
+    // Use the offset seen while collecting info on globals.
+    uint64_t Offset = CVGlobalVariableOffsets.lookup(DIGV);
     OS.emitCOFFSecRel32(GVSym, Offset);
 
     OS.AddComment("Segment");



More information about the llvm-commits mailing list