[PATCH] D120377: [lld-macho] Implement -why_live (without perf overhead)

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 12:16:24 PST 2022


thakis added inline comments.


================
Comment at: lld/MachO/MarkLive.cpp:111
+    if (!symbols.empty())
+      lld::errs() << std::string(indent, ' ') << toString(*symbols.front())
+                  << " from " << toString(symbols.front()->getFile()) << "\n";
----------------
int3 wrote:
> thakis wrote:
> > can you add a comment on why this doesn't use message()?
> oh yeah... I was thinking about how we would handle parallelization in the future, and I realized that `message()` wasn't ideal here because it would take one lock per call, whereas we want to take one lock for the whole of `printWhyLiveImpl` so that the lines wouldn't get interleaved with other concurrent messages. I'll add that comment.
Oh, good point. But maybe it's nicer to accumulate the message in a string and only call message() once at the end? Then we need to hold the lock for a shorter time.

(Are our bumpptr allocators in a per-thread tls?)


================
Comment at: lld/MachO/MarkLive.cpp:187
+              referentIsec = d->isec;
+            enqueue(isec, 0, makeEntry(referentIsec, nullptr));
+          }
----------------
thakis wrote:
> Do you want a `makeEntry(nullptr, nullptr)` for Undefineds here, or a `nullptr`?
> 
> Hm, I guess an Undefined never has relocs. Do we always have a Defined here? If so, we should probably just `cast<>` without conditional.
> 
> If there are non-Undefined non-Defined cases, the original question if you want `makeEntry(nullptr, nullptr)` stands for that :)
(this is still open)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120377



More information about the llvm-commits mailing list