[llvm] fbec1c2 - [NFC][CodeLayout] Remove unused parameter (#110145)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 10:28:12 PDT 2024
Author: Ellis Hoag
Date: 2024-09-26T10:28:06-07:00
New Revision: fbec1c2a08ce2ae9750ddf3cecc86c5dd2bbc9d8
URL: https://github.com/llvm/llvm-project/commit/fbec1c2a08ce2ae9750ddf3cecc86c5dd2bbc9d8
DIFF: https://github.com/llvm/llvm-project/commit/fbec1c2a08ce2ae9750ddf3cecc86c5dd2bbc9d8.diff
LOG: [NFC][CodeLayout] Remove unused parameter (#110145)
The `NodeCounts` parameter of `calcExtTspScore()` is unused, so remove
it.
Use `SmallVector` since arrays are expected to be small since they
represent MBBs.
Added:
Modified:
llvm/include/llvm/Transforms/Utils/CodeLayout.h
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/lib/Transforms/Utils/CodeLayout.cpp
Removed:
################################################################################
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