[PATCH] D117173: [ORC-RT] Hook objc's class_getImageName for JITDylibs

Ben Langmuir via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 14:24:27 PDT 2022


benlangmuir added inline comments.


================
Comment at: compiler-rt/lib/orc/executor_address.h:196-206
+    auto I = Map.lower_bound({Addr, Addr});
+    if (I != end() && I->first.contains(Addr))
+      return I;
+    // Since we search based on the start of the range, we need to check the
+    // previous element as well.
+    if (I != begin()) {
+      --I;
----------------
lhames wrote:
> What about using upper-bound here? It has the advantage that you only need to check one range, though you do have to special-case the empty map.
> 
> ```
> if (Map.empty())
>   return Map.end();
> auto I = std::prev(Map.upper_bound({Addr, Addr}));
> if (I->first.contains(Addr))
>   return I;
> return Map.end();
> ```
> 
I think this would work, although you need to check `I != Map.begin()` before calling `prev` I believe.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117173/new/

https://reviews.llvm.org/D117173



More information about the llvm-commits mailing list