DW_TAG_partial_unit is remapped on each of its use, those remapped virtual units are added into DWARFDebugInfo::m_compile_units during multithreaded indexing.
I am not sure what do you prefer about m_compile_units_size_atomic. Overhead of the new mutex will not be measurable in practice I think:
(1) Drop any such atomic_t for its size and always use the mutex.
(2) Use atomic_t to prevent mutex locking in most common cases. But maintain it separately which is error prone during newly coded m_compile_units updates. --- attached patch implements this
(3) Provide m_compile_units class wrapper which transparently updates also its atomic_t.
All DWZ patches are also applied in: git clone -b dwz git://git.jankratochvil.net/lldb