diff options
| author | Fangrui Song <maskray@google.com> | 2019-04-06 09:12:53 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-04-06 09:12:53 +0000 |
| commit | 4be8629e4930e2c4cffca41c8cbf438b3aa05e85 (patch) | |
| tree | 29beb64c6d21801f14e012b84fcddec07f6dd5ca /llvm/lib | |
| parent | cb300f124360abf1a6640926f2dc478a45ce6b1f (diff) | |
| download | bcm5719-llvm-4be8629e4930e2c4cffca41c8cbf438b3aa05e85.tar.gz bcm5719-llvm-4be8629e4930e2c4cffca41c8cbf438b3aa05e85.zip | |
[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*).
llvm-svn: 357834
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp index d4714b4fb3a..a28313676eb 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -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; } |

