Skip to content

Commit dee96a3

Browse files
authored
[llvm][IR][NFC] Apply clang-tidy fixes to ProfDataUtils (#136447)
A few functions in the TU could be made static, and a loop variable name could be changed to avoid warnings.
1 parent bf33f03 commit dee96a3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

llvm/lib/IR/ProfDataUtils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool isBranchWeightMD(const MDNode *ProfileData) {
9696
return isTargetMD(ProfileData, "branch_weights", MinBWOps);
9797
}
9898

99-
bool isValueProfileMD(const MDNode *ProfileData) {
99+
static bool isValueProfileMD(const MDNode *ProfileData) {
100100
return isTargetMD(ProfileData, "VP", MinVPOps);
101101
}
102102

@@ -105,7 +105,7 @@ bool hasBranchWeightMD(const Instruction &I) {
105105
return isBranchWeightMD(ProfileData);
106106
}
107107

108-
bool hasCountTypeMD(const Instruction &I) {
108+
static bool hasCountTypeMD(const Instruction &I) {
109109
auto *ProfileData = I.getMetadata(LLVMContext::MD_prof);
110110
// Value profiles record count-type information.
111111
if (isValueProfileMD(ProfileData))
@@ -271,16 +271,16 @@ void scaleProfData(Instruction &I, uint64_t S, uint64_t T) {
271271
Vals.push_back(MDB.createConstant(ConstantInt::get(
272272
Type::getInt32Ty(C), Val.udiv(APT).getLimitedValue(UINT32_MAX))));
273273
} else if (ProfDataName->getString() == "VP")
274-
for (unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
274+
for (unsigned Idx = 1; Idx < ProfileData->getNumOperands(); Idx += 2) {
275275
// The first value is the key of the value profile, which will not change.
276-
Vals.push_back(ProfileData->getOperand(i));
276+
Vals.push_back(ProfileData->getOperand(Idx));
277277
uint64_t Count =
278-
mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i + 1))
278+
mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(Idx + 1))
279279
->getValue()
280280
.getZExtValue();
281281
// Don't scale the magic number.
282282
if (Count == NOMORE_ICP_MAGICNUM) {
283-
Vals.push_back(ProfileData->getOperand(i + 1));
283+
Vals.push_back(ProfileData->getOperand(Idx + 1));
284284
continue;
285285
}
286286
// Using APInt::div may be expensive, but most cases should fit 64 bits.

0 commit comments

Comments
 (0)