[llvm] [NFC][CodeLayout] Remove unused parameter (PR #110145)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:01:11 PDT 2024
https://github.com/ellishg created https://github.com/llvm/llvm-project/pull/110145
The `NodeCounts` parameter of `calcExtTspScore()` is unused, so remove it.
Use `SmallVector` since arrays are expected to be small since they represent MBBs.
>From 85f5640e8cb56ca32c690885033dbbafe7716531 Mon Sep 17 00:00:00 2001
From: Ellis Hoag <ellis.sparky.hoag at gmail.com>
Date: Thu, 26 Sep 2024 09:34:58 -0700
Subject: [PATCH] [NFC][CodeLayout] Remove unused parameter
---
.../llvm/Transforms/Utils/CodeLayout.h | 2 --
llvm/lib/CodeGen/MachineBlockPlacement.cpp | 11 +++++-----
llvm/lib/Transforms/Utils/CodeLayout.cpp | 20 ++++++++-----------
3 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/llvm/include/llvm/Transforms/Utils/CodeLayout.h b/llvm/include/llvm/Transforms/Utils/CodeLayout.h
index 3ba8b9137113b7..c737643ee1014a 100644
--- a/llvm/include/llvm/Transforms/Utils/CodeLayout.h
+++ b/llvm/include/llvm/Transforms/Utils/CodeLayout.h
@@ -49,12 +49,10 @@ std::vector<uint64_t> computeExtTspLayout(ArrayRef<uint64_t> NodeSizes,
/// the given order, which is anti-correlated with the number of I-cache misses
/// in a typical execution of the function.
double calcExtTspScore(ArrayRef<uint64_t> Order, ArrayRef<uint64_t> NodeSizes,
- ArrayRef<uint64_t> NodeCounts,
ArrayRef<EdgeCount> EdgeCounts);
/// Estimate the "quality" of the current node order in CFG.
double calcExtTspScore(ArrayRef<uint64_t> NodeSizes,
- ArrayRef<uint64_t> NodeCounts,
ArrayRef<EdgeCount> EdgeCounts);
/// Algorithm-specific params for Cache-Directed Sort. The values are tuned for
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index a52c82d77ca644..7807875c06584c 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -3619,9 +3619,8 @@ void MachineBlockPlacement::applyExtTsp() {
<< " with profile = " << F->getFunction().hasProfileData()
<< " (" << F->getName().str() << ")"
<< "\n");
- LLVM_DEBUG(
- dbgs() << format(" original layout score: %0.2f\n",
- calcExtTspScore(BlockSizes, BlockCounts, JumpCounts)));
+ LLVM_DEBUG(dbgs() << format(" original layout score: %0.2f\n",
+ calcExtTspScore(BlockSizes, JumpCounts)));
// Run the layout algorithm.
auto NewOrder = computeExtTspLayout(BlockSizes, BlockCounts, JumpCounts);
@@ -3630,9 +3629,9 @@ void MachineBlockPlacement::applyExtTsp() {
for (uint64_t Node : NewOrder) {
NewBlockOrder.push_back(CurrentBlockOrder[Node]);
}
- LLVM_DEBUG(dbgs() << format(" optimized layout score: %0.2f\n",
- calcExtTspScore(NewOrder, BlockSizes, BlockCounts,
- JumpCounts)));
+ LLVM_DEBUG(
+ dbgs() << format(" optimized layout score: %0.2f\n",
+ calcExtTspScore(NewOrder, BlockSizes, JumpCounts)));
// Assign new block order.
assignBlockOrder(NewBlockOrder);
diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index 95edd27c675d24..baaad8bb48f33d 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -1427,20 +1427,18 @@ codelayout::computeExtTspLayout(ArrayRef<uint64_t> NodeSizes,
double codelayout::calcExtTspScore(ArrayRef<uint64_t> Order,
ArrayRef<uint64_t> NodeSizes,
- ArrayRef<uint64_t> NodeCounts,
ArrayRef<EdgeCount> EdgeCounts) {
// Estimate addresses of the blocks in memory.
- std::vector<uint64_t> Addr(NodeSizes.size(), 0);
- for (size_t Idx = 1; Idx < Order.size(); Idx++) {
+ SmallVector<uint64_t> Addr(NodeSizes.size(), 0);
+ for (uint64_t Idx = 1; Idx < Order.size(); Idx++)
Addr[Order[Idx]] = Addr[Order[Idx - 1]] + NodeSizes[Order[Idx - 1]];
- }
- std::vector<uint64_t> OutDegree(NodeSizes.size(), 0);
- for (auto Edge : EdgeCounts)
+ SmallVector<uint64_t> OutDegree(NodeSizes.size(), 0);
+ for (auto &Edge : EdgeCounts)
++OutDegree[Edge.src];
// Increase the score for each jump.
double Score = 0;
- for (auto Edge : EdgeCounts) {
+ for (auto &Edge : EdgeCounts) {
bool IsConditional = OutDegree[Edge.src] > 1;
Score += ::extTSPScore(Addr[Edge.src], NodeSizes[Edge.src], Addr[Edge.dst],
Edge.count, IsConditional);
@@ -1449,13 +1447,11 @@ double codelayout::calcExtTspScore(ArrayRef<uint64_t> Order,
}
double codelayout::calcExtTspScore(ArrayRef<uint64_t> NodeSizes,
- ArrayRef<uint64_t> NodeCounts,
ArrayRef<EdgeCount> EdgeCounts) {
- std::vector<uint64_t> Order(NodeSizes.size());
- for (size_t Idx = 0; Idx < NodeSizes.size(); Idx++) {
+ SmallVector<uint64_t> Order(NodeSizes.size());
+ for (uint64_t Idx = 0; Idx < NodeSizes.size(); Idx++)
Order[Idx] = Idx;
- }
- return calcExtTspScore(Order, NodeSizes, NodeCounts, EdgeCounts);
+ return calcExtTspScore(Order, NodeSizes, EdgeCounts);
}
std::vector<uint64_t> codelayout::computeCacheDirectedLayout(
More information about the llvm-commits
mailing list