This is an archive of the discontinued LLVM Phabricator instance.

[llvm-profdata] Changed SampleProfWriter to take a range of of NameFunctionSamples
Needs ReviewPublic

Authored by huangjd on Jul 13 2023, 8:07 PM.

Details

Summary

Most functions in SampleProfWriter previously taking a
SampleProfileMap now take llvm::ArrayRef<NameFunctionSamples> instead.
The original write interface takes a SampleProfileMap and immediately
sorts it into a vector<NameFunctionSamples> before passing it down to
the actual write implementations.

The purpose of this change is to allow SampleProfWriter to take a slice
of the profile to write to file, instead of having to modify or
reconstruct a SampleProfileMap, which is very slow. In a following patch
I am going to enhance the functionality of reducing profile size limit,
which will make heavy use of the new SampleProfWriter interface.

Diff Detail

Event Timeline

huangjd created this revision.Jul 13 2023, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 8:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
huangjd requested review of this revision.Jul 13 2023, 8:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 8:07 PM
huangjd retitled this revision from [llvm-profdata]Changed SampleProWriter to take a range of of NameFunctionSamples to [llvm-profdata] Changed SampleProfWriter to take a range of of NameFunctionSamples.Jul 13 2023, 8:07 PM

A meta comment -- when the parameter type is change, the name of the parameter should also be changed. In this case 'profileMap' is no longer meaningful.

llvm/include/llvm/ProfileData/SampleProf.h
1562

using template to share code with flattenProfile above?