29
29
namespace llvm {
30
30
31
31
// This structure represents a unique ID for every block specified in the
32
- // profile.
32
+ // input profile.
33
33
struct ProfileBBID {
34
+ // Basic block id associated with `MachineBasicBlock::BBID`.
34
35
unsigned BBID;
36
+ // The clone id associated with the block. This is zero for the original
37
+ // block. For the cloned ones, it is equal to 1 + index of the associated
38
+ // path in `RawFunctionProfile::ClonePaths`.
35
39
unsigned CloneID;
36
40
};
37
41
42
+ // This struct represents the cluster information for a machine basic block,
43
+ // which is specifed by a unique ID. This templated struct is used for both the
44
+ // raw input profile (as `BBProfle<ProfileBBID>`) and the processed profile
45
+ // after applying the clonings (as `BBProfile<unsigned>`).
46
+ template <typename BBIDType> struct BBProfile {
47
+ // Basic block ID.
48
+ BBIDType BasicBlockID;
49
+ // Cluster ID this basic block belongs to.
50
+ unsigned ClusterID;
51
+ // Position of basic block within the cluster.
52
+ unsigned PositionInCluster;
53
+ };
54
+
55
+ // This represents the raw input profile for one function.
56
+ struct RawFunctionProfile {
57
+ // BB Cluster information specified by `ProfileBBID`s (before cloning).
58
+ SmallVector<BBProfile<ProfileBBID>> RawBBProfiles;
59
+ // Paths to clone. A path a -> b -> c -> d implies cloning b, c, and d along
60
+ // the edge a -> b (a is not cloned). The index of the path in this vector
61
+ // determines the `ProfileBBID::CloneID` of the cloned blocks in that path.
62
+ SmallVector<SmallVector<unsigned >> ClonePaths;
63
+ };
64
+
38
65
// Provides DenseMapInfo for ProfileBBID.
39
66
template <> struct DenseMapInfo <ProfileBBID> {
40
67
static inline ProfileBBID getEmptyKey () {
@@ -56,26 +83,6 @@ template <> struct DenseMapInfo<ProfileBBID> {
56
83
}
57
84
};
58
85
59
- // This struct represents the cluster information for a machine basic block,
60
- // which is specifed by a unique ID.
61
- template <typename BBIDType> struct BBProfile {
62
- // Basic block ID.
63
- BBIDType BasicBlockID;
64
- // Cluster ID this basic block belongs to.
65
- unsigned ClusterID;
66
- // Position of basic block within the cluster.
67
- unsigned PositionInCluster;
68
- };
69
-
70
- // This represents the profile for one function.
71
- struct RawFunctionProfile {
72
- // BB Cluster information specified by `ProfileBBID`s (before cloning).
73
- SmallVector<BBProfile<ProfileBBID>> RawBBProfiles;
74
- // Paths to clone. A path a -> b -> c -> d implies cloning b, c, and d along
75
- // the edge a -> b.
76
- SmallVector<SmallVector<unsigned >> ClonePaths;
77
- };
78
-
79
86
class BasicBlockSectionsProfileReader : public ImmutablePass {
80
87
public:
81
88
static char ID;
@@ -110,7 +117,7 @@ class BasicBlockSectionsProfileReader : public ImmutablePass {
110
117
getRawProfileForFunction (StringRef FuncName) const ;
111
118
112
119
// Initializes the FunctionNameToDIFilename map for the current module and
113
- // then reads the profile for matching functions.
120
+ // then reads the profile for the matching functions.
114
121
bool doInitialization (Module &M) override ;
115
122
116
123
private:
@@ -150,7 +157,7 @@ class BasicBlockSectionsProfileReader : public ImmutablePass {
150
157
// empty string if no debug info is available.
151
158
StringMap<SmallString<128 >> FunctionNameToDIFilename;
152
159
153
- // This encapsulates the BB cluster information for the whole program.
160
+ // This contains the BB cluster information for the whole program.
154
161
//
155
162
// For every function name, it contains the cloning and cluster information
156
163
// for (all or some of) its basic blocks. The cluster information for every
@@ -159,7 +166,7 @@ class BasicBlockSectionsProfileReader : public ImmutablePass {
159
166
StringMap<RawFunctionProfile> RawProgramProfile;
160
167
161
168
// Some functions have alias names. We use this map to find the main alias
162
- // name for which we have mapping in ProgramBBClusterInfo .
169
+ // name which appears in RawProgramProfile as a key .
163
170
StringMap<StringRef> FuncAliasMap;
164
171
};
165
172
0 commit comments