LLVM 22.0.0git
StaticDataProfileInfo.h
Go to the documentation of this file.
1#ifndef LLVM_ANALYSIS_STATICDATAPROFILEINFO_H
2#define LLVM_ANALYSIS_STATICDATAPROFILEINFO_H
3
4#include "llvm/ADT/DenseMap.h"
5#include "llvm/ADT/DenseSet.h"
7#include "llvm/IR/Constant.h"
8#include "llvm/Pass.h"
10
11namespace llvm {
12
13/// A class that holds the constants that represent static data and their
14/// profile information and provides methods to operate on them.
16public:
17 /// Accummulate the profile count of a constant that will be lowered to static
18 /// data sections.
20
21 /// Keeps track of the constants that are seen at least once without profile
22 /// counts.
24
25 /// If \p C has a count, return it. Otherwise, return std::nullopt.
26 LLVM_ABI std::optional<uint64_t>
28
29public:
31
32 /// If \p Count is not nullopt, add it to the profile count of the constant \p
33 /// C in a saturating way, and clamp the count to \p getInstrMaxCountValue if
34 /// the result exceeds it. Otherwise, mark the constant as having no profile
35 /// count.
37 std::optional<uint64_t> Count);
38
39 /// Return a section prefix for the constant \p C based on its profile count.
40 /// - If a constant doesn't have a counter, return an empty string.
41 /// - Otherwise,
42 /// - If it has a hot count, return "hot".
43 /// - If it is seen by unprofiled function, return an empty string.
44 /// - If it has a cold count, return "unlikely".
45 /// - Otherwise (e.g. it's used by lukewarm functions), return an empty
46 /// string.
48 const Constant *C, const ProfileSummaryInfo *PSI) const;
49};
50
51/// This wraps the StaticDataProfileInfo object as an immutable pass, for a
52/// backend pass to operate on.
54public:
55 static char ID;
57 bool doInitialization(Module &M) override;
58 bool doFinalization(Module &M) override;
59
62 return *Info;
63 }
64
65 /// This pass provides StaticDataProfileInfo for reads/writes but does not
66 /// modify \p M or other analysis. All analysis are preserved.
67 void getAnalysisUsage(AnalysisUsage &AU) const override {
68 AU.setPreservesAll();
69 }
70
71private:
72 std::unique_ptr<StaticDataProfileInfo> Info;
73};
74
75} // namespace llvm
76
77#endif // LLVM_ANALYSIS_STATICDATAPROFILEINFO_H
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_ABI
Definition: Compiler.h:213
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
This is an important base class in LLVM.
Definition: Constant.h:43
Implements a dense probed hash-table based set.
Definition: DenseSet.h:263
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:285
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Analysis providing profile information.
This wraps the StaticDataProfileInfo object as an immutable pass, for a backend pass to operate on.
const StaticDataProfileInfo & getStaticDataProfileInfo() const
void getAnalysisUsage(AnalysisUsage &AU) const override
This pass provides StaticDataProfileInfo for reads/writes but does not modify M or other analysis.
StaticDataProfileInfo & getStaticDataProfileInfo()
A class that holds the constants that represent static data and their profile information and provide...
LLVM_ABI std::optional< uint64_t > getConstantProfileCount(const Constant *C) const
If C has a count, return it. Otherwise, return std::nullopt.
LLVM_ABI void addConstantProfileCount(const Constant *C, std::optional< uint64_t > Count)
If Count is not nullopt, add it to the profile count of the constant C in a saturating way,...
LLVM_ABI StringRef getConstantSectionPrefix(const Constant *C, const ProfileSummaryInfo *PSI) const
Return a section prefix for the constant C based on its profile count.
DenseMap< const Constant *, uint64_t > ConstantProfileCounts
Accummulate the profile count of a constant that will be lowered to static data sections.
DenseSet< const Constant * > ConstantWithoutCounts
Keeps track of the constants that are seen at least once without profile counts.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18