[llvm] [BPF] Use heterogeneous lookup with std::map (NFC) (PR #143395)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 08:26:46 PDT 2025


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

None

>From e09abf47fdfe57be7d742c4f203d41d3069aedea Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 8 Jun 2025 23:44:57 -0700
Subject: [PATCH] [BPF] Use heterogeneous lookup with std::map (NFC)

---
 llvm/lib/Target/BPF/BTFDebug.cpp | 2 +-
 llvm/lib/Target/BPF/BTFDebug.h   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index 978cd9ab2106e..1d7c6fc799ff3 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -1438,7 +1438,7 @@ void BTFDebug::processGlobals(bool ProcessingMapDef) {
     // constant with private linkage and if it won't be in .rodata.str<#>
     // and .rodata.cst<#> sections.
     if (SecName == ".rodata" && Global.hasPrivateLinkage() &&
-        DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) {
+        DataSecEntries.find(SecName) == DataSecEntries.end()) {
       // skip .rodata.str<#> and .rodata.cst<#> sections
       if (!GVKind->isMergeableCString() && !GVKind->isMergeableConst()) {
         DataSecEntries[std::string(SecName)] =
diff --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h
index b24a79de74efa..75858fcc8bfde 100644
--- a/llvm/lib/Target/BPF/BTFDebug.h
+++ b/llvm/lib/Target/BPF/BTFDebug.h
@@ -300,7 +300,8 @@ class BTFDebug : public DebugHandlerBase {
   std::map<uint32_t, std::vector<BTFLineInfo>> LineInfoTable;
   std::map<uint32_t, std::vector<BTFFieldReloc>> FieldRelocTable;
   StringMap<std::vector<std::string>> FileContent;
-  std::map<std::string, std::unique_ptr<BTFKindDataSec>> DataSecEntries;
+  std::map<std::string, std::unique_ptr<BTFKindDataSec>, std::less<>>
+      DataSecEntries;
   std::vector<BTFTypeStruct *> StructTypes;
   std::map<const GlobalVariable *, std::pair<int64_t, uint32_t>> PatchImms;
   std::map<const DICompositeType *,



More information about the llvm-commits mailing list