In debug info correlation mode we do not emit the data globals so we
need to explicitly mark the counter globals as used so they don't get
stripped.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
My understanding is that the counter symbol is referenced by a text/code. So it's naturally retained as long as the function is kept.
Is there any specific case this needs to be explicitly used?
Ah thank you. I've since ran some experiments and found that after https://reviews.llvm.org/D116051 the number of profiled functions is about what we expect without this patch. However, I'm working on another patch that only profiles function entry coverage and this code change is needed in that case. I'll do more investigation and follow up here.
After further investigation we realized this patch is needed even for the normal block count case. Currently, it seems the optimizer does not remove globals when they are incremented because it requires a read and a write. In theory this optimization is safe so we should explicitly mark these globals as used.