-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm][IR][NFC] Apply clang-tidy fixes to ProfDataUtils #136447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A few functions in the TU could be made static, and a loop variable name could be changed to avoid warnings.
@llvm/pr-subscribers-llvm-ir Author: Paul Kirth (ilovepi) ChangesA few functions in the TU could be made static, and a loop variable name Full diff: https://github.com/llvm/llvm-project/pull/136447.diff 1 Files Affected:
diff --git a/llvm/lib/IR/ProfDataUtils.cpp b/llvm/lib/IR/ProfDataUtils.cpp
index 5441228b3291e..9046373414a6c 100644
--- a/llvm/lib/IR/ProfDataUtils.cpp
+++ b/llvm/lib/IR/ProfDataUtils.cpp
@@ -96,7 +96,7 @@ bool isBranchWeightMD(const MDNode *ProfileData) {
return isTargetMD(ProfileData, "branch_weights", MinBWOps);
}
-bool isValueProfileMD(const MDNode *ProfileData) {
+static bool isValueProfileMD(const MDNode *ProfileData) {
return isTargetMD(ProfileData, "VP", MinVPOps);
}
@@ -105,7 +105,7 @@ bool hasBranchWeightMD(const Instruction &I) {
return isBranchWeightMD(ProfileData);
}
-bool hasCountTypeMD(const Instruction &I) {
+static bool hasCountTypeMD(const Instruction &I) {
auto *ProfileData = I.getMetadata(LLVMContext::MD_prof);
// Value profiles record count-type information.
if (isValueProfileMD(ProfileData))
@@ -271,16 +271,16 @@ void scaleProfData(Instruction &I, uint64_t S, uint64_t T) {
Vals.push_back(MDB.createConstant(ConstantInt::get(
Type::getInt32Ty(C), Val.udiv(APT).getLimitedValue(UINT32_MAX))));
} else if (ProfDataName->getString() == "VP")
- for (unsigned i = 1; i < ProfileData->getNumOperands(); i += 2) {
+ for (unsigned Idx = 1; Idx < ProfileData->getNumOperands(); Idx += 2) {
// The first value is the key of the value profile, which will not change.
- Vals.push_back(ProfileData->getOperand(i));
+ Vals.push_back(ProfileData->getOperand(Idx));
uint64_t Count =
- mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i + 1))
+ mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(Idx + 1))
->getValue()
.getZExtValue();
// Don't scale the magic number.
if (Count == NOMORE_ICP_MAGICNUM) {
- Vals.push_back(ProfileData->getOperand(i + 1));
+ Vals.push_back(ProfileData->getOperand(Idx + 1));
continue;
}
// Using APInt::div may be expensive, but most cases should fit 64 bits.
|
petrhosek
approved these changes
Apr 20, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
A few functions in the TU could be made static, and a loop variable name could be changed to avoid warnings.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
A few functions in the TU could be made static, and a loop variable name could be changed to avoid warnings.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
A few functions in the TU could be made static, and a loop variable name could be changed to avoid warnings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few functions in the TU could be made static, and a loop variable name
could be changed to avoid warnings.