[llvm] [PowerPC] Avoid repeated hash lookups (NFC) (PR #132514)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 21 20:58:18 PDT 2025


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

None

>From 8fe2c412a75122d3c37bd3af42f4abc035fcc5be Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 21 Mar 2025 08:34:47 -0700
Subject: [PATCH] [PowerPC] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 358dffcd8dce8..ba6653e10bdc5 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -510,10 +510,11 @@ MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(const MCSymbol *Sym,
                                                 TOCEntryType Type,
                                                 PPCMCExpr::Specifier Spec) {
   // If this is a new TOC entry add statistics about it.
-  if (!TOC.contains({Sym, Spec}))
+  auto [It, Inserted] = TOC.try_emplace({Sym, Spec});
+  if (Inserted)
     collectTOCStats(Type);
 
-  MCSymbol *&TOCEntry = TOC[{Sym, Spec}];
+  MCSymbol *&TOCEntry = It->second;
   if (!TOCEntry)
     TOCEntry = createTempSymbol("C");
   return TOCEntry;



More information about the llvm-commits mailing list