[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 16 10:34:50 PDT 2024


https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/102904

>From 3ffb03f8e4bcb2fa235ae989320c466af4a3cda8 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Mon, 12 Aug 2024 14:40:57 -0700
Subject: [PATCH 1/2] stable_sort

Created using spr 1.3.4
---
 llvm/lib/MC/MCPseudoProbe.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 45fe95e176ff24..1c81630dda4dd9 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -638,7 +638,7 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
   std::vector<std::pair<uint64_t, uint32_t>> SortedA2P(ProbeCount);
   for (const auto &[I, Probe] : llvm::enumerate(PseudoProbeVec))
     SortedA2P[I] = {Probe.getAddress(), I};
-  llvm::sort(SortedA2P, llvm::less_first());
+  llvm::stable_sort(SortedA2P, llvm::less_first());
   Address2ProbesMap.reserve(ProbeCount);
   for (const uint32_t I : llvm::make_second_range(SortedA2P))
     Address2ProbesMap.emplace_back(PseudoProbeVec[I]);

>From 445b646bbf9718f98689cae92d9bc71366d80e31 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Fri, 16 Aug 2024 10:34:40 -0700
Subject: [PATCH 2/2] Check find addr

Created using spr 1.3.4
---
 llvm/include/llvm/MC/MCPseudoProbe.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h
index edac9b94e28f44..559e8ff9055df9 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -228,6 +228,8 @@ class AddressProbesMap
     auto FromIt = getIt(Address);
     if (FromIt == end())
       return llvm::make_range(end(), end());
+    if (FromIt->get().getAddress() != Address)
+      return llvm::make_range(end(), end());
     auto ToIt = getIt(Address + 1);
     return llvm::make_range(FromIt, ToIt);
   }



More information about the llvm-branch-commits mailing list