From 61aca6ef798aa918833be6125d4600cb95a585ce Mon Sep 17 00:00:00 2001 From: Kyle Butt Date: Tue, 30 Aug 2016 18:18:54 +0000 Subject: [PATCH] TailDuplication: Extract Indirect-Branch block limit as option. NFC The existing code hard-coded a limit of 20 instructions for duplication when a block ended with an indirect branch. Extract this as an option. No functional change intended. llvm-svn: 280125 --- llvm/include/llvm/CodeGen/TailDuplicator.h | 2 ++ llvm/lib/CodeGen/TailDuplicator.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TailDuplicator.h b/llvm/include/llvm/CodeGen/TailDuplicator.h index cd13627f7870..6037a12063f9 100644 --- a/llvm/include/llvm/CodeGen/TailDuplicator.h +++ b/llvm/include/llvm/CodeGen/TailDuplicator.h @@ -26,6 +26,8 @@ namespace llvm { +extern cl::opt TailDupIndirectBranchSize; + /// Utility class to perform tail duplication. class TailDuplicator { const TargetInstrInfo *TII; diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index a27e38d2d7d6..5434ff66ea54 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -40,12 +40,20 @@ STATISTIC(NumTailDupRemoved, STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumAddedPHIs, "Number of phis added"); +namespace llvm { + // Heuristic for tail duplication. static cl::opt TailDuplicateSize( "tail-dup-size", cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2), cl::Hidden); +cl::opt TailDupIndirectBranchSize( + "tail-dup-indirect-size", + cl::desc("Maximum instructions to consider tail duplicating blocks that " + "end with indirect branches."), cl::init(20), + cl::Hidden); + static cl::opt TailDupVerify("tail-dup-verify", cl::desc("Verify sanity of PHI instructions during taildup"), @@ -54,8 +62,6 @@ static cl::opt static cl::opt TailDupLimit("tail-dup-limit", cl::init(~0U), cl::Hidden); -namespace llvm { - void TailDuplicator::initMF(MachineFunction &MFin, const MachineBranchProbabilityInfo *MBPIin, unsigned TailDupSizeIn) { @@ -550,7 +556,7 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple, HasIndirectbr = TailBB.back().isIndirectBranch(); if (HasIndirectbr && PreRegAlloc) - MaxDuplicateCount = 20; + MaxDuplicateCount = TailDupIndirectBranchSize; // Check the instructions in the block to determine whether tail-duplication // is invalid or unlikely to be profitable.