[PATCH] D74773: [LLD][Debuginfo] create DWARFContext only once for the same object file.

Alexey Lapshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 08:30:03 PST 2020


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


================
Comment at: lld/ELF/InputFiles.cpp:309
+template <class ELFT> llvm::DWARFContext *ObjFile<ELFT>::getDWARFContext() {
+  llvm::call_once(initDwarf, [this]() { initializeDwarf(); });
+
----------------
ruiu wrote:
> Calling call_once from multiple places doesn't seem to be a very good way to manage object instantiation. How about this?
> 
>  - Define getDwarf() function that returns a DWARFCache object. That function initializes Dwarf member if it is not initialized yet
>  - Remove initializeDwarf (since now getDwarf initializes the Dwarf member)
>  - Remove getDWARFContext and rewrite `getDWARFContext()` with `getDwarf()->getContext()`
> 
Just to make things clear - call_once would still be used. But it would be used in single place - inside getDwarf() function - right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74773





More information about the llvm-commits mailing list