File indexing completed on 2026-05-10 08:44:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_TRANSFORMS_UTILS_SAMPLEPROFILELOADERBASEUTIL_H
0016 #define LLVM_TRANSFORMS_UTILS_SAMPLEPROFILELOADERBASEUTIL_H
0017
0018 #include "llvm/ADT/DenseMap.h"
0019 #include "llvm/ProfileData/SampleProf.h"
0020 #include "llvm/Support/CommandLine.h"
0021
0022 namespace llvm {
0023 using namespace sampleprof;
0024
0025 class ProfileSummaryInfo;
0026 class Module;
0027
0028 extern cl::opt<unsigned> SampleProfileMaxPropagateIterations;
0029 extern cl::opt<unsigned> SampleProfileRecordCoverage;
0030 extern cl::opt<unsigned> SampleProfileSampleCoverage;
0031 extern cl::opt<bool> NoWarnSampleUnused;
0032
0033 namespace sampleprofutil {
0034
0035 class SampleCoverageTracker {
0036 public:
0037 bool markSamplesUsed(const FunctionSamples *FS, uint32_t LineOffset,
0038 uint32_t Discriminator, uint64_t Samples);
0039 unsigned computeCoverage(unsigned Used, unsigned Total) const;
0040 unsigned countUsedRecords(const FunctionSamples *FS,
0041 ProfileSummaryInfo *PSI) const;
0042 unsigned countBodyRecords(const FunctionSamples *FS,
0043 ProfileSummaryInfo *PSI) const;
0044 uint64_t getTotalUsedSamples() const { return TotalUsedSamples; }
0045 uint64_t countBodySamples(const FunctionSamples *FS,
0046 ProfileSummaryInfo *PSI) const;
0047
0048 void clear() {
0049 SampleCoverage.clear();
0050 TotalUsedSamples = 0;
0051 }
0052 void setProfAccForSymsInList(bool V) { ProfAccForSymsInList = V; }
0053
0054 private:
0055 using BodySampleCoverageMap = std::map<LineLocation, unsigned>;
0056 using FunctionSamplesCoverageMap =
0057 DenseMap<const FunctionSamples *, BodySampleCoverageMap>;
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 FunctionSamplesCoverageMap SampleCoverage;
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 uint64_t TotalUsedSamples = 0;
0082
0083
0084
0085 bool ProfAccForSymsInList = false;
0086 };
0087
0088
0089 bool callsiteIsHot(const FunctionSamples *CallsiteFS, ProfileSummaryInfo *PSI,
0090 bool ProfAccForSymsInList);
0091
0092
0093 void createFSDiscriminatorVariable(Module *M);
0094
0095 }
0096 }
0097
0098 #endif