TailDuplication: Extract Indirect-Branch block limit as option. NFC
authorKyle Butt <kyle+llvm@iteratee.net>
Tue, 30 Aug 2016 18:18:54 +0000 (18:18 +0000)
committerKyle Butt <kyle+llvm@iteratee.net>
Tue, 30 Aug 2016 18:18:54 +0000 (18:18 +0000)
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
llvm/lib/CodeGen/TailDuplicator.cpp

index cd13627..6037a12 100644 (file)
@@ -26,6 +26,8 @@
 
 namespace llvm {
 
+extern cl::opt<unsigned> TailDupIndirectBranchSize;
+
 /// Utility class to perform tail duplication.
 class TailDuplicator {
   const TargetInstrInfo *TII;
index a27e38d..5434ff6 100644 (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.