This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Sample PGO] Avoid non-const accessor for CallsiteSamples
ClosedPublic

Authored by wenlei on Jun 28 2023, 12:03 PM.

Details

Summary

Exposing a non-const accessor for clearing CallsiteSamples during flattening is a big of an overkill. Replace the non-const accessor with removeAllCallsiteSamples.

Diff Detail

Event Timeline

wenlei created this revision.Jun 28 2023, 12:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 12:03 PM
Herald added a subscriber: modimo. · View Herald Transcript
wenlei requested review of this revision.Jun 28 2023, 12:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 12:03 PM
wlei accepted this revision.Jun 28 2023, 12:07 PM

Good catch!

This revision is now accepted and ready to land.Jun 28 2023, 12:07 PM
hoy accepted this revision.Jun 28 2023, 12:09 PM
marksantaniello added inline comments.
llvm/include/llvm/ProfileData/SampleProf.h
806

Consider "the swap trick" to guarantee that we free the memory?

CallsiteSamplesMap EmptyCallsiteSamples;
std::swap(CallsiteSamples, EmptyCallsiteSamples);
wenlei added inline comments.Jun 28 2023, 1:42 PM
llvm/include/llvm/ProfileData/SampleProf.h
806

It's a std::map, so clear should be sufficient.

This revision was landed with ongoing or failed builds.Jun 28 2023, 1:44 PM
This revision was automatically updated to reflect the committed changes.