diff options
author | Krzysztof Pszeniczny <kpszeniczny@google.com> | 2024-07-24 17:43:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-24 17:43:26 +0200 |
commit | 5bae81ba9e6db16fac3cc0ee96b134f3f588c8f4 (patch) | |
tree | 8a4b4610acbef1399f9a826576fb1a94e81c269e /llvm/lib/CodeGen/MachineBlockPlacement.cpp | |
parent | 0c03b4ce1081383b7649ac0f5ba3cbaffaf5bf28 (diff) | |
download | llvm-5bae81ba9e6db16fac3cc0ee96b134f3f588c8f4.zip llvm-5bae81ba9e6db16fac3cc0ee96b134f3f588c8f4.tar.gz llvm-5bae81ba9e6db16fac3cc0ee96b134f3f588c8f4.tar.bz2 |
[CodeGen] Add an option to skip extTSP BB placement for huge functions. (#99310)
The extTSP-based basic block layout algorithm improves the performance
of the generated code, but unfortunately it has a super-linear time
complexity. This leads to extremely long compilation times for certain
relatively rare kinds of autogenerated code.
This patch adds an `-mllvm` flag to optionally restrict extTSP only to
functions smaller than a specified threshold. While commit
bcdc0477319a26fd8dcdde5ace3bdd6743599f44 added a knob to to limit the
maximum chain size, it's still possible that for certain huge functions
the number of chains is very large, leading to a quadratic behaviour in
ExtTSPImpl::mergeChainPairs.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index cb352a5..6179e09 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -213,6 +213,12 @@ static cl::opt<bool> RenumberBlocksBeforeView( "into a dot graph. Only used when a function is being printed."), cl::init(false), cl::Hidden); +static cl::opt<unsigned> ExtTspBlockPlacementMaxBlocks( + "ext-tsp-block-placement-max-blocks", + cl::desc("Maximum number of basic blocks in a function to run ext-TSP " + "block placement."), + cl::init(UINT_MAX), cl::Hidden); + namespace llvm { extern cl::opt<bool> EnableExtTspBlockPlacement; extern cl::opt<bool> ApplyExtTspWithoutProfile; @@ -3523,7 +3529,8 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) { // Apply a post-processing optimizing block placement. if (MF.size() >= 3 && EnableExtTspBlockPlacement && - (ApplyExtTspWithoutProfile || MF.getFunction().hasProfileData())) { + (ApplyExtTspWithoutProfile || MF.getFunction().hasProfileData()) && + MF.size() <= ExtTspBlockPlacementMaxBlocks) { // Find a new placement and modify the layout of the blocks in the function. applyExtTsp(); |