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
This commit is contained in:
Kyle Butt 2016-08-30 18:18:54 +00:00
parent eb666b7ac5
commit 61aca6ef79
2 changed files with 11 additions and 3 deletions

View File

@ -26,6 +26,8 @@
namespace llvm {
extern cl::opt<unsigned> TailDupIndirectBranchSize;
/// Utility class to perform tail duplication.
class TailDuplicator {
const TargetInstrInfo *TII;

View File

@ -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<unsigned> TailDuplicateSize(
"tail-dup-size",
cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2),
cl::Hidden);
cl::opt<unsigned> 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<bool>
TailDupVerify("tail-dup-verify",
cl::desc("Verify sanity of PHI instructions during taildup"),
@ -54,8 +62,6 @@ static cl::opt<bool>
static cl::opt<unsigned> 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.