Skip to content

[NFC][CodeLayout] Remove unused parameter #110145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions llvm/include/llvm/Transforms/Utils/CodeLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions llvm/lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
20 changes: 8 additions & 12 deletions llvm/lib/Transforms/Utils/CodeLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down
Loading