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

Daniel Bertalan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 19 10:42:23 PDT 2022


BertalanD marked an inline comment as done.
BertalanD added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:509
+
+    optimizationHints.push_back(
+        {type, {address[0], address[1], address[2]}, minAddress});
----------------
grandinj wrote:
> I'm guessing if you run a profiler over this (like perf), you will see significant time spent in resizing/re-allocating the vector.
> You could avoid this by calling reserve before the loop to reserve storage.
> 
> Alternatively, just use std::deque instead. It handles this case well, and doesn't need to re-allocate/resize.
We need `optimizationHints` to be a contiguous block of memory if we want to store an `ArrayRef<OptimizationHint>` in each (sub)section. That way, it's faster than making many smaller `vector<OptimizationHint>` allocations for each `InputSection`.

The data is encoded in the variable length ULEB128 format, so we don't exactly know how many elements there are until we've parsed the section fully  and encountered the terminating element. But we can make an (over)estimation.


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

https://reviews.llvm.org/D128093



More information about the llvm-commits mailing list