[llvm] [InstrProf] Adding utility weights to BalancedPartitioning (PR #72717)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 10:14:54 PST 2024
================
@@ -905,6 +905,20 @@ void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
ValueSites.emplace_back(VData, VData + N);
}
+// Deduplicate utility nodes for a given function.
+// TODO: One may experiment with accumulating the weights of duplicates.
+void sortAndDeduplicate(SmallVector<BPFunctionNode::UtilityNodeT, 4> &UNs) {
+ using UtilityNodeT = BPFunctionNode::UtilityNodeT;
+ llvm::sort(UNs, [](const UtilityNodeT &L, const UtilityNodeT &R) {
+ return L.Id < R.Id;
+ });
+ UNs.erase(std::unique(UNs.begin(), UNs.end(),
+ [](const UtilityNodeT &L, const UtilityNodeT &R) {
+ return L.Id == R.Id;
+ }),
+ UNs.end());
+}
+
----------------
ellishg wrote:
Since this can be useful outside of `InstrProf.cpp`, I think we should move this to be a static function of `UtilityNodeT`.
https://github.com/llvm/llvm-project/pull/72717
More information about the llvm-commits
mailing list