aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-09-21 13:13:03 -0700
committerFangrui Song <i@maskray.me>2023-09-21 13:13:03 -0700
commit6b8d04c23dbcc156c24c4152ac36eb6c384cb361 (patch)
treeb8de2ab48e736c1df2700a682fffe972ffb29463 /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parente6ebd2890f0edbe1759f96a5e42075b716ca5e18 (diff)
downloadllvm-6b8d04c23dbcc156c24c4152ac36eb6c384cb361.zip
llvm-6b8d04c23dbcc156c24c4152ac36eb6c384cb361.tar.gz
llvm-6b8d04c23dbcc156c24c4152ac36eb6c384cb361.tar.bz2
[CodeLayout] Refactor std::vector uses, namespace, and EdgeCountT. NFC
* Place types and functions in the llvm::codelayout namespace * Change EdgeCountT from pair<pair<uint64_t, uint64_t>, uint64_t> to a struct and utilize structured bindings. It is not conventional to use the "T" suffix for structure types. * Remove a redundant copy in ChainT::merge. * Change {ExtTSPImpl,CDSortImpl}::run to use return value instead of an output parameter * Rename applyCDSLayout to computeCacheDirectedLayout: (a) avoid rare abbreviation "CDS" (cache-directed sort) (b) "compute" is more conventional for the specific use case * Change the parameter types from std::vector to ArrayRef so that SmallVector arguments can be used. * Similarly, rename applyExtTspLayout to computeExtTspLayout. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D159526
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 24f0197..603c0e9 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -3501,7 +3501,7 @@ void MachineBlockPlacement::applyExtTsp() {
auto BlockSizes = std::vector<uint64_t>(F->size());
auto BlockCounts = std::vector<uint64_t>(F->size());
- std::vector<EdgeCountT> JumpCounts;
+ std::vector<codelayout::EdgeCount> JumpCounts;
for (MachineBasicBlock &MBB : *F) {
// Getting the block frequency.
BlockFrequency BlockFreq = MBFI->getBlockFreq(&MBB);
@@ -3520,8 +3520,8 @@ void MachineBlockPlacement::applyExtTsp() {
for (MachineBasicBlock *Succ : MBB.successors()) {
auto EP = MBPI->getEdgeProbability(&MBB, Succ);
BlockFrequency JumpFreq = BlockFreq * EP;
- auto Jump = std::make_pair(BlockIndex[&MBB], BlockIndex[Succ]);
- JumpCounts.push_back(std::make_pair(Jump, JumpFreq.getFrequency()));
+ JumpCounts.push_back(
+ {BlockIndex[&MBB], BlockIndex[Succ], JumpFreq.getFrequency()});
}
}
@@ -3534,7 +3534,7 @@ void MachineBlockPlacement::applyExtTsp() {
calcExtTspScore(BlockSizes, BlockCounts, JumpCounts)));
// Run the layout algorithm.
- auto NewOrder = applyExtTspLayout(BlockSizes, BlockCounts, JumpCounts);
+ auto NewOrder = computeExtTspLayout(BlockSizes, BlockCounts, JumpCounts);
std::vector<const MachineBasicBlock *> NewBlockOrder;
NewBlockOrder.reserve(F->size());
for (uint64_t Node : NewOrder) {