[llvm] [llvm][IR][NFC] Apply clang-tidy fixes to ProfDataUtils (PR #136447)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 19 11:46:03 PDT 2025


https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/136447

A few functions in the TU could be made static, and a loop variable name
could be changed to avoid warnings.

>From fcc3f0ba3ec8e6825e7d3198cdf4ca29664681c3 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Sat, 19 Apr 2025 11:43:34 -0700
Subject: [PATCH] [llvm][IR][NFC] Apply clang-tidy fixes to ProfDataUtils

A few functions in the TU could be made static, and a loop variable name
could be changed to avoid warnings.
---
 llvm/lib/IR/ProfDataUtils.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

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.



More information about the llvm-commits mailing list