Skip to content

Commit e9afb2d

Browse files
committed
Address review comments.
Changing variable names and comments.
1 parent 5336259 commit e9afb2d

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ class BasicBlockSectionsProfileReader : public ImmutablePass {
134134
inconvertibleErrorCode());
135135
}
136136

137-
// Parses a `ProfileBBID` from `S`. `S` should be in the form "<bbid>" (representing an original block) or "<bbid>.<cloneid>" (representing a cloned block) where bbid is a non-negative integer and cloneid is a positive integer.
137+
// Parses a `ProfileBBID` from `S`. `S` must be in the form "<bbid>"
138+
// (representing an original block) or "<bbid>.<cloneid>" (representing a
139+
// cloned block) where bbid is a non-negative integer and cloneid is a
140+
// positive integer.
138141
Expected<ProfileBBID> parseProfileBBID(StringRef S) const;
139142

140143
// Reads the basic block sections profile for functions in this module.

llvm/lib/CodeGen/BasicBlockSections.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,18 @@ bool BasicBlockSections::runOnMachineFunction(MachineFunction &MF) {
311311
DenseMap<unsigned, BBClusterInfo<unsigned>> ClusterInfoByBBID;
312312
if (BBSectionsType == BasicBlockSection::List) {
313313
auto [HasProfile, PathAndClusterInfo] =
314-
getAnalysis<BasicBlockSectionsProfileReader>().getPathAndClusterInfoForFunction(
315-
MF.getName());
314+
getAnalysis<BasicBlockSectionsProfileReader>()
315+
.getPathAndClusterInfoForFunction(MF.getName());
316316
if (!HasProfile)
317317
return true;
318-
for (const BBClusterInfo<ProfileBBID> &BBP : PathAndClusterInfo.ClusterInfo) {
318+
for (const BBClusterInfo<ProfileBBID> &BBP :
319+
PathAndClusterInfo.ClusterInfo) {
319320
// TODO: Apply the path cloning profile.
320321
assert(!BBP.BasicBlockID.CloneID && "Path cloning is not supported yet");
321322
const auto [I, Inserted] = ClusterInfoByBBID.try_emplace(
322323
BBP.BasicBlockID.BBID,
323324
BBClusterInfo<unsigned>{BBP.BasicBlockID.BBID, BBP.ClusterID,
324-
BBP.PositionInCluster});
325+
BBP.PositionInCluster});
325326
(void)I;
326327
assert(Inserted && "Duplicate BBID found in profile");
327328
}

llvm/lib/CodeGen/BasicBlockSectionsProfileReader.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ std::pair<bool, FunctionPathAndClusterInfo>
6363
BasicBlockSectionsProfileReader::getPathAndClusterInfoForFunction(
6464
StringRef FuncName) const {
6565
auto R = ProgramPathAndClusterInfo.find(getAliasName(FuncName));
66-
return R != ProgramPathAndClusterInfo.end() ? std::pair(true, R->second)
67-
: std::pair(false, FunctionPathAndClusterInfo());
66+
return R != ProgramPathAndClusterInfo.end()
67+
? std::pair(true, R->second)
68+
: std::pair(false, FunctionPathAndClusterInfo());
6869
}
6970

7071
// Reads the version 1 basic block sections profile. Profile for each function
@@ -85,10 +86,13 @@ BasicBlockSectionsProfileReader::getPathAndClusterInfoForFunction(
8586
// clone basic blocks along a path. The cloned blocks are then specified in the
8687
// cluster information.
8788
// The following profile lists two cloning paths (starting with 'p') for
88-
// function bar and places the total 9 blocks within two clusters. The blocks in each path are cloned along the path from the first block (the first block is not cloned).
89-
// For instance, path 1 (1 -> 3 -> 4) specifies that 3 and 4 must be cloned along the edge 1->3. In the clusters, each cloned
90-
// block is identified by its original block id, along with its clone id. For instance, the cloned blocks from path 1 are represented by 3.1 and 4.1.
91-
// A block cloned multiple times appears with distinct clone ids. The CFG for bar
89+
// function bar and places the total 9 blocks within two clusters. The first two
90+
// blocks of a cloning path specify the edge along which the path is cloned. For
91+
// instance, path 1 (1 -> 3 -> 4) instructs that 3 and 4 must be cloned along
92+
// the edge 1->3. Within the given clusters, each cloned block is identified by
93+
// "<original block id>.<clone id>". For instance, 3.1 represents the first
94+
// clone of block 3. Original blocks are specified just with their block ids. A
95+
// block cloned multiple times appears with distinct clone ids. The CFG for bar
9296
// is shown below before and after cloning with its final clusters labeled.
9397
//
9498
// f main
@@ -279,8 +283,8 @@ Error BasicBlockSectionsProfileReader::ReadV0Profile() {
279283

280284
FI->second.ClusterInfo.emplace_back(
281285
BBClusterInfo<ProfileBBID>({{static_cast<unsigned>(BBID), 0},
282-
CurrentCluster,
283-
CurrentPosition++}));
286+
CurrentCluster,
287+
CurrentPosition++}));
284288
}
285289
CurrentCluster++;
286290
} else {

0 commit comments

Comments
 (0)