[PATCH] D128093: [lld-macho] Initial support for Linker Optimization Hints

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 25 17:24:15 PDT 2022


thakis added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:492-493
+      if (expectedCount == -1) {
+        warn("Linker optimization hint at offset " + Twine(inputOffset) +
+             " has unknown type " + Twine(type));
+        // Skip it.
----------------
int3 wrote:
> BertalanD wrote:
> > int3 wrote:
> > > do we actually expect this to happen in practice? can we just error out and return early?
> > I added it for forward compatibility.
> > 
> > However, it looks like the LLVM pass that emits these hints hasn't been changed substantially for a long time, so it's probably safe to say that we won't be getting any new types that will be need to handled.
> Gotcha. I would also argue that we should expect people to upgrade LLD and clang in lockstep most of the time, so we don't need to worry too much about forwards compatibility
+1


================
Comment at: lld/MachO/Relocations.h:81
+
+struct OptimizationHint {
+  uint8_t type;
----------------
ld64 packs this into a single 64-bit word (cf `union LOH_arm64` in ld.hpp) and does a bunch of range checks to make sure that fits (cf `Section<arm64>::addLOH`, macho_relocatable_file.cpp). Could we do that too? Probably helps with perf (?)


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

https://reviews.llvm.org/D128093



More information about the llvm-commits mailing list