diff options
author | Fangrui Song <i@maskray.me> | 2023-09-21 13:13:03 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-09-21 13:13:03 -0700 |
commit | 6b8d04c23dbcc156c24c4152ac36eb6c384cb361 (patch) | |
tree | b8de2ab48e736c1df2700a682fffe972ffb29463 /bolt/lib/Passes/ReorderAlgorithm.cpp | |
parent | e6ebd2890f0edbe1759f96a5e42075b716ca5e18 (diff) | |
download | llvm-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 'bolt/lib/Passes/ReorderAlgorithm.cpp')
-rw-r--r-- | bolt/lib/Passes/ReorderAlgorithm.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bolt/lib/Passes/ReorderAlgorithm.cpp b/bolt/lib/Passes/ReorderAlgorithm.cpp index b5052cd..3c3365e 100644 --- a/bolt/lib/Passes/ReorderAlgorithm.cpp +++ b/bolt/lib/Passes/ReorderAlgorithm.cpp @@ -531,21 +531,21 @@ void ExtTSPReorderAlgorithm::reorderBasicBlocks(BinaryFunction &BF, } // Initialize CFG edges - using JumpT = std::pair<uint64_t, uint64_t>; - std::vector<std::pair<JumpT, uint64_t>> JumpCounts; + std::vector<codelayout::EdgeCount> JumpCounts; for (BinaryBasicBlock *BB : BF.getLayout().blocks()) { auto BI = BB->branch_info_begin(); for (BinaryBasicBlock *SuccBB : BB->successors()) { assert(BI->Count != BinaryBasicBlock::COUNT_NO_PROFILE && "missing profile for a jump"); - auto It = std::make_pair(BB->getLayoutIndex(), SuccBB->getLayoutIndex()); - JumpCounts.push_back(std::make_pair(It, BI->Count)); + JumpCounts.push_back( + {BB->getLayoutIndex(), SuccBB->getLayoutIndex(), BI->Count}); ++BI; } } // Run the layout algorithm - auto Result = applyExtTspLayout(BlockSizes, BlockCounts, JumpCounts); + auto Result = + codelayout::computeExtTspLayout(BlockSizes, BlockCounts, JumpCounts); Order.reserve(BF.getLayout().block_size()); for (uint64_t R : Result) Order.push_back(OrigOrder[R]); |