This is an archive of the discontinued LLVM Phabricator instance.

[InstrProf] Mark counters as used in debug correlation mode
ClosedPublic

Authored by ellis on Dec 17 2021, 5:11 PM.

Details

Summary

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.

Diff Detail

Event Timeline

ellis created this revision.Dec 17 2021, 5:11 PM
ellis published this revision for review.Dec 17 2021, 5:26 PM
ellis added reviewers: kyulee, MaskRay.
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2021, 5:26 PM

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?

ellis planned changes to this revision.EditedDec 20 2021, 1:19 PM

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.

ellis abandoned this revision.Dec 22 2021, 11:35 AM

This patch was absorbed into https://reviews.llvm.org/D116180

ellis reclaimed this revision.Dec 28 2021, 2:33 PM

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.

ellis updated this revision to Diff 396434.Dec 28 2021, 2:36 PM

Rebase.

kyulee accepted this revision.Dec 30 2021, 2:43 PM

LGTM

This revision is now accepted and ready to land.Dec 30 2021, 2:43 PM
This revision was landed with ongoing or failed builds.Dec 30 2021, 2:51 PM
This revision was automatically updated to reflect the committed changes.