================ @@ -213,6 +208,31 @@ 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:
Should this be `if (FromIt->getAddress() != Address)`?, iiuc, it will return the first greater element iterator not always the `end()` if the key doesn't exist. https://github.com/llvm/llvm-project/pull/102904 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits