`__sancov_pcs` parallels the other metadata section(s). While some optimizers (e.g. GlobalDCE) respect linker semantics for comdat and retain or discard the sections as a unit, some (e.g. GlobalOpt/ConstantMerge) do not. So we have to conservatively retain all unconditionally in the compiler. When a comdat is used, the COFF/ELF linkers' GC semantics ensure the associated parallel array elements are retained or discarded together, so `llvm.compiler.used` is sufficient. Otherwise (MachO (see rL311955/rL311959), COFF special case where comdat is not used), we have to use `llvm.used` to conservatively make all sections retain by the linker. This will fix the Windows problem once internal linkage GlobalObject's in `llvm.used` are retained via `/INCLUDE:`. Reviewed By: morehouse, vitalybuka Differential Revision: https://reviews.llvm.org/D97432
41 KiB
41 KiB