[llvm-branch-commits] [llvm] [MC][NFC] Reduce Address2ProbesMap size (PR #102904)
Lei Wang via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 19 10:09:54 PDT 2024
================
@@ -213,6 +208,33 @@ class MCDecodedPseudoProbe : public MCPseudoProbeBase {
bool ShowName) const;
};
+// Address to pseudo probes map.
+class AddressProbesMap
+ : public std::vector<std::reference_wrapper<MCDecodedPseudoProbe>> {
+ auto getIt(uint64_t Addr) const {
+ auto CompareProbe = [](const MCDecodedPseudoProbe &Probe, uint64_t Addr) {
+ return Probe.getAddress() < Addr;
+ };
+ return llvm::lower_bound(*this, Addr, CompareProbe);
+ }
+
+public:
+ // Returns range of probes within [\p From, \p To) address range.
+ auto find(uint64_t From, uint64_t To) const {
+ return llvm::make_range(getIt(From), getIt(To));
+ }
+ // Returns range of probes with given \p Address.
+ auto find(uint64_t Address) const {
+ auto FromIt = getIt(Address);
+ if (FromIt == end())
----------------
wlei-llvm wrote:
nit: `if (FromIt == end() || FromIt->get().getAddress() != Address) ...`
https://github.com/llvm/llvm-project/pull/102904
More information about the llvm-branch-commits
mailing list