LLVM 22.0.0git
llvm::sampleprof::FunctionPruningStrategy Class Referenceabstract

When writing a profile with size limit, user may want to use a different strategy to reduce function count other than dropping functions with fewest samples first. More...

#include "llvm/ProfileData/SampleProfWriter.h"

Inheritance diagram for llvm::sampleprof::FunctionPruningStrategy:
[legend]

Public Member Functions

 FunctionPruningStrategy (SampleProfileMap &ProfileMap, size_t OutputSizeLimit)
 ProfileMap A reference to the original profile map.
virtual ~FunctionPruningStrategy ()=default
virtual void Erase (size_t CurrentOutputSize)=0
 SampleProfileWriter::writeWithSizeLimit() calls this after every write iteration if the output size still exceeds the limit.

Protected Attributes

SampleProfileMapProfileMap
size_t OutputSizeLimit

Detailed Description

When writing a profile with size limit, user may want to use a different strategy to reduce function count other than dropping functions with fewest samples first.

In this case a class implementing the same interfaces should be provided to SampleProfileWriter::writeWithSizeLimit().

Definition at line 43 of file SampleProfWriter.h.

Constructor & Destructor Documentation

◆ FunctionPruningStrategy()

llvm::sampleprof::FunctionPruningStrategy::FunctionPruningStrategy ( SampleProfileMap & ProfileMap,
size_t OutputSizeLimit )
inline

ProfileMap A reference to the original profile map.

It will be modified by Erase(). OutputSizeLimit Size limit in bytes of the output profile. This is necessary to estimate how many functions to remove.

Definition at line 53 of file SampleProfWriter.h.

References OutputSizeLimit, and ProfileMap.

Referenced by llvm::sampleprof::DefaultFunctionPruningStrategy::DefaultFunctionPruningStrategy().

◆ ~FunctionPruningStrategy()

virtual llvm::sampleprof::FunctionPruningStrategy::~FunctionPruningStrategy ( )
virtualdefault

Member Function Documentation

◆ Erase()

virtual void llvm::sampleprof::FunctionPruningStrategy::Erase ( size_t CurrentOutputSize)
pure virtual

SampleProfileWriter::writeWithSizeLimit() calls this after every write iteration if the output size still exceeds the limit.

This function should erase some functions from the profile map so that the writer tries to write the profile again with fewer functions. At least 1 entry from the profile map must be erased.

CurrentOutputSize Number of bytes in the output if current profile map is written.

Implemented in llvm::sampleprof::DefaultFunctionPruningStrategy.

Referenced by llvm::sampleprof::SampleProfileWriter::writeWithSizeLimitInternal().

Member Data Documentation

◆ OutputSizeLimit

size_t llvm::sampleprof::FunctionPruningStrategy::OutputSizeLimit
protected

◆ ProfileMap


The documentation for this class was generated from the following file: