[llvm] r357834 - [DWARF] Simplify DWARFDebugAranges::findAddress
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 8 13:50:08 PDT 2019
Nice! thanks!
On Sat, Apr 6, 2019 at 2:11 AM Fangrui Song via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: maskray
> Date: Sat Apr 6 02:12:53 2019
> New Revision: 357834
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357834&view=rev
> Log:
> [DWARF] Simplify DWARFDebugAranges::findAddress
>
> The current lower_bound approach has to check two iterators pos and pos-1.
> Changing it to upper_bound allows us to check one iterator (similar to
> DWARFUnitVector::getUnitFor*).
>
> Modified:
> llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
> llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
>
> Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h?rev=357834&r1=357833&r2=357834&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h Sat Apr 6 02:12:53 2019
> @@ -49,10 +49,6 @@ private:
> return -1ULL;
> }
>
> - bool containsAddress(uint64_t Address) const {
> - return LowPC <= Address && Address < HighPC();
> - }
> -
> bool operator<(const Range &other) const {
> return LowPC < other.LowPC;
> }
>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp?rev=357834&r1=357833&r2=357834&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp Sat Apr 6 02:12:53 2019
> @@ -114,20 +114,11 @@ void DWARFDebugAranges::construct() {
> }
>
> uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
> - if (!Aranges.empty()) {
> - Range range(Address);
> - RangeCollIterator begin = Aranges.begin();
> - RangeCollIterator end = Aranges.end();
> - RangeCollIterator pos =
> - std::lower_bound(begin, end, range);
> -
> - if (pos != end && pos->containsAddress(Address)) {
> - return pos->CUOffset;
> - } else if (pos != begin) {
> - --pos;
> - if (pos->containsAddress(Address))
> - return pos->CUOffset;
> - }
> - }
> + RangeCollIterator It =
> + llvm::upper_bound(Aranges, Address, [](uint64_t LHS, Range RHS) {
> + return LHS < RHS.HighPC();
> + });
> + if (It != Aranges.end() && It->LowPC <= Address)
> + return It->CUOffset;
> return -1U;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list