diff options
| author | Fangrui Song <i@maskray.me> | 2025-06-20 20:13:04 -0700 |
|---|---|---|
| committer | Fangrui Song <i@maskray.me> | 2025-06-20 20:13:04 -0700 |
| commit | 95fbfc9be5d2842a945c04a20fe6244df9b10e18 (patch) | |
| tree | 00f80558d11aa5805e6d6f290663c6da44e5e6ef /llvm/lib/CodeGen/MachineBlockPlacement.cpp | |
| parent | a9ba028b98ffd53d9c7d00ca7563d74810fcf6e7 (diff) | |
| parent | 17e8465a3eb0cae48b9f62d27fd26f2b070f1f9b (diff) | |
[𝘀𝗽𝗿] changes introduced through rebaseusers/MaskRay/spr/main.move-relocation-specifier-constants-to-aarch64
Created using spr 1.3.5-bogner
[skip ci]
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineBlockPlacement.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 08fe3d47e2ff..2dbabfe345d5 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -104,6 +104,12 @@ static cl::opt<unsigned> MaxBytesForAlignmentOverride( "alignment"), cl::init(0), cl::Hidden); +static cl::opt<unsigned> PredecessorLimit( + "block-placement-predecessor-limit", + cl::desc("For blocks with more predecessors, certain layout optimizations" + "will be disabled to prevent quadratic compile time."), + cl::init(1000), cl::Hidden); + // FIXME: Find a good default for this flag and remove the flag. static cl::opt<unsigned> ExitBlockBias( "block-placement-exit-block-bias", @@ -1030,6 +1036,11 @@ bool MachineBlockPlacement::isTrellis( SmallPtrSet<const MachineBasicBlock *, 8> SeenPreds; for (MachineBasicBlock *Succ : ViableSuccs) { + // Compile-time optimization: runtime is quadratic in the number of + // predecessors. For such uncommon cases, exit early. + if (Succ->pred_size() > PredecessorLimit) + return false; + int PredCount = 0; for (auto *SuccPred : Succ->predecessors()) { // Allow triangle successors, but don't count them. @@ -1472,6 +1483,11 @@ bool MachineBlockPlacement::hasBetterLayoutPredecessor( if (SuccChain.UnscheduledPredecessors == 0) return false; + // Compile-time optimization: runtime is quadratic in the number of + // predecessors. For such uncommon cases, exit early. + if (Succ->pred_size() > PredecessorLimit) + return false; + // There are two basic scenarios here: // ------------------------------------- // Case 1: triangular shape CFG (if-then): |
