[llvm] [ProfileData] Remove the old version of getValueProfDataFromInst (PR #97374)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 19:07:23 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
I've migrated uses of the old version of getValueProfDataFromInst to
the one that returns SmallVector<InstrProfValueData, 4>. This patch
removes the old version.
---
Full diff: https://github.com/llvm/llvm-project/pull/97374.diff
2 Files Affected:
- (modified) llvm/include/llvm/ProfileData/InstrProf.h (-10)
- (modified) llvm/lib/ProfileData/InstrProf.cpp (-45)
``````````diff
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index 50e6f1d3b9b1f..9b34cb0b651f7 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -284,16 +284,6 @@ void annotateValueSite(Module &M, Instruction &Inst,
ArrayRef<InstrProfValueData> VDs, uint64_t Sum,
InstrProfValueKind ValueKind, uint32_t MaxMDCount);
-/// Extract the value profile data from \p Inst and returns them if \p Inst is
-/// annotated with value profile data. Returns nullptr otherwise. It's similar
-/// to `getValueProfDataFromInst` above except that an array is allocated only
-/// after a preliminary checking that the value profiles of kind `ValueKind`
-/// exist.
-std::unique_ptr<InstrProfValueData[]>
-getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
- uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
- uint64_t &TotalC, bool GetNoICPValue = false);
-
// TODO: Unify metadata name 'PGOFuncName' and 'PGOName', by supporting read
// of this metadata for backward compatibility and generating 'PGOName' only.
/// Extract the value profile data from \p Inst and returns them if \p Inst is
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 9dbaa2ca0f020..4695285787cf3 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -1342,51 +1342,6 @@ MDNode *mayHaveValueProfileOfKind(const Instruction &Inst,
return MD;
}
-static bool getValueProfDataFromInstImpl(const MDNode *const MD,
- const uint32_t MaxNumDataWant,
- InstrProfValueData ValueData[],
- uint32_t &ActualNumValueData,
- uint64_t &TotalC, bool GetNoICPValue) {
- const unsigned NOps = MD->getNumOperands();
- // Get total count
- ConstantInt *TotalCInt = mdconst::dyn_extract<ConstantInt>(MD->getOperand(2));
- if (!TotalCInt)
- return false;
- TotalC = TotalCInt->getZExtValue();
- ActualNumValueData = 0;
-
- for (unsigned I = 3; I < NOps; I += 2) {
- if (ActualNumValueData >= MaxNumDataWant)
- break;
- ConstantInt *Value = mdconst::dyn_extract<ConstantInt>(MD->getOperand(I));
- ConstantInt *Count =
- mdconst::dyn_extract<ConstantInt>(MD->getOperand(I + 1));
- if (!Value || !Count)
- return false;
- uint64_t CntValue = Count->getZExtValue();
- if (!GetNoICPValue && (CntValue == NOMORE_ICP_MAGICNUM))
- continue;
- ValueData[ActualNumValueData].Value = Value->getZExtValue();
- ValueData[ActualNumValueData].Count = CntValue;
- ActualNumValueData++;
- }
- return true;
-}
-
-std::unique_ptr<InstrProfValueData[]>
-getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
- uint32_t MaxNumValueData, uint32_t &ActualNumValueData,
- uint64_t &TotalC, bool GetNoICPValue) {
- MDNode *MD = mayHaveValueProfileOfKind(Inst, ValueKind);
- if (!MD)
- return nullptr;
- auto ValueDataArray = std::make_unique<InstrProfValueData[]>(MaxNumValueData);
- if (!getValueProfDataFromInstImpl(MD, MaxNumValueData, ValueDataArray.get(),
- ActualNumValueData, TotalC, GetNoICPValue))
- return nullptr;
- return ValueDataArray;
-}
-
SmallVector<InstrProfValueData, 4>
getValueProfDataFromInst(const Instruction &Inst, InstrProfValueKind ValueKind,
uint32_t MaxNumValueData, uint64_t &TotalC,
``````````
</details>
https://github.com/llvm/llvm-project/pull/97374
More information about the llvm-commits
mailing list