[PATCH] D108850: [LLD] Remove global state in lldCommon

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 3 15:14:26 PDT 2021


aganea added a comment.

In D108850#2978142 <https://reviews.llvm.org/D108850#2978142>, @akhuang wrote:

> This is cool, I was also looking at refactoring out some of the globals in lldCOFF (for now just trying to move some globals into existing classes and passing the classes around). Looks good to me, although I'm not very familiar with structuring code in this way / making things work with threads.

Both concepts can coexist, passing references to objects across calls, or accesing them through a global (essentially what the mechanism this patch provides). In some cases it just isn't practical to pass references (`lld::outs` for example, or anything related to the `lld::ErrorHandler`).



================
Comment at: lld/Common/Globals.cpp:45
+// valid LLD instance, through `attachContext()`.
+static LLVM_THREAD_LOCAL CommonLinkingContext *lctx;
+} // namespace
----------------
akhuang wrote:
> does static make the anonymous namespace unnecessary?
Yes indeed, fixed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108850



More information about the llvm-commits mailing list