Skip to content

Commit fbec1c2

Browse files
authored
[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.
1 parent bc6bd3b commit fbec1c2

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

llvm/include/llvm/Transforms/Utils/CodeLayout.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ std::vector<uint64_t> computeExtTspLayout(ArrayRef<uint64_t> NodeSizes,
4949
/// the given order, which is anti-correlated with the number of I-cache misses
5050
/// in a typical execution of the function.
5151
double calcExtTspScore(ArrayRef<uint64_t> Order, ArrayRef<uint64_t> NodeSizes,
52-
ArrayRef<uint64_t> NodeCounts,
5352
ArrayRef<EdgeCount> EdgeCounts);
5453

5554
/// Estimate the "quality" of the current node order in CFG.
5655
double calcExtTspScore(ArrayRef<uint64_t> NodeSizes,
57-
ArrayRef<uint64_t> NodeCounts,
5856
ArrayRef<EdgeCount> EdgeCounts);
5957

6058
/// Algorithm-specific params for Cache-Directed Sort. The values are tuned for

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,9 +3619,8 @@ void MachineBlockPlacement::applyExtTsp() {
36193619
<< " with profile = " << F->getFunction().hasProfileData()
36203620
<< " (" << F->getName().str() << ")"
36213621
<< "\n");
3622-
LLVM_DEBUG(
3623-
dbgs() << format(" original layout score: %0.2f\n",
3624-
calcExtTspScore(BlockSizes, BlockCounts, JumpCounts)));
3622+
LLVM_DEBUG(dbgs() << format(" original layout score: %0.2f\n",
3623+
calcExtTspScore(BlockSizes, JumpCounts)));
36253624

36263625
// Run the layout algorithm.
36273626
auto NewOrder = computeExtTspLayout(BlockSizes, BlockCounts, JumpCounts);
@@ -3630,9 +3629,9 @@ void MachineBlockPlacement::applyExtTsp() {
36303629
for (uint64_t Node : NewOrder) {
36313630
NewBlockOrder.push_back(CurrentBlockOrder[Node]);
36323631
}
3633-
LLVM_DEBUG(dbgs() << format(" optimized layout score: %0.2f\n",
3634-
calcExtTspScore(NewOrder, BlockSizes, BlockCounts,
3635-
JumpCounts)));
3632+
LLVM_DEBUG(
3633+
dbgs() << format(" optimized layout score: %0.2f\n",
3634+
calcExtTspScore(NewOrder, BlockSizes, JumpCounts)));
36363635

36373636
// Assign new block order.
36383637
assignBlockOrder(NewBlockOrder);

llvm/lib/Transforms/Utils/CodeLayout.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,20 +1427,18 @@ codelayout::computeExtTspLayout(ArrayRef<uint64_t> NodeSizes,
14271427

14281428
double codelayout::calcExtTspScore(ArrayRef<uint64_t> Order,
14291429
ArrayRef<uint64_t> NodeSizes,
1430-
ArrayRef<uint64_t> NodeCounts,
14311430
ArrayRef<EdgeCount> EdgeCounts) {
14321431
// Estimate addresses of the blocks in memory.
1433-
std::vector<uint64_t> Addr(NodeSizes.size(), 0);
1434-
for (size_t Idx = 1; Idx < Order.size(); Idx++) {
1432+
SmallVector<uint64_t> Addr(NodeSizes.size(), 0);
1433+
for (uint64_t Idx = 1; Idx < Order.size(); Idx++)
14351434
Addr[Order[Idx]] = Addr[Order[Idx - 1]] + NodeSizes[Order[Idx - 1]];
1436-
}
1437-
std::vector<uint64_t> OutDegree(NodeSizes.size(), 0);
1438-
for (auto Edge : EdgeCounts)
1435+
SmallVector<uint64_t> OutDegree(NodeSizes.size(), 0);
1436+
for (auto &Edge : EdgeCounts)
14391437
++OutDegree[Edge.src];
14401438

14411439
// Increase the score for each jump.
14421440
double Score = 0;
1443-
for (auto Edge : EdgeCounts) {
1441+
for (auto &Edge : EdgeCounts) {
14441442
bool IsConditional = OutDegree[Edge.src] > 1;
14451443
Score += ::extTSPScore(Addr[Edge.src], NodeSizes[Edge.src], Addr[Edge.dst],
14461444
Edge.count, IsConditional);
@@ -1449,13 +1447,11 @@ double codelayout::calcExtTspScore(ArrayRef<uint64_t> Order,
14491447
}
14501448

14511449
double codelayout::calcExtTspScore(ArrayRef<uint64_t> NodeSizes,
1452-
ArrayRef<uint64_t> NodeCounts,
14531450
ArrayRef<EdgeCount> EdgeCounts) {
1454-
std::vector<uint64_t> Order(NodeSizes.size());
1455-
for (size_t Idx = 0; Idx < NodeSizes.size(); Idx++) {
1451+
SmallVector<uint64_t> Order(NodeSizes.size());
1452+
for (uint64_t Idx = 0; Idx < NodeSizes.size(); Idx++)
14561453
Order[Idx] = Idx;
1457-
}
1458-
return calcExtTspScore(Order, NodeSizes, NodeCounts, EdgeCounts);
1454+
return calcExtTspScore(Order, NodeSizes, EdgeCounts);
14591455
}
14601456

14611457
std::vector<uint64_t> codelayout::computeCacheDirectedLayout(

0 commit comments

Comments
 (0)