Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 63347e9

Browse files
author
Kyle Butt
committed
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280125 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 2f1f35b commit 63347e9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

include/llvm/CodeGen/TailDuplicator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
namespace llvm {
2828

29+
extern cl::opt<unsigned> TailDupIndirectBranchSize;
30+
2931
/// Utility class to perform tail duplication.
3032
class TailDuplicator {
3133
const TargetInstrInfo *TII;

lib/CodeGen/TailDuplicator.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@ STATISTIC(NumTailDupRemoved,
4040
STATISTIC(NumDeadBlocks, "Number of dead blocks removed");
4141
STATISTIC(NumAddedPHIs, "Number of phis added");
4242

43+
namespace llvm {
44+
4345
// Heuristic for tail duplication.
4446
static cl::opt<unsigned> TailDuplicateSize(
4547
"tail-dup-size",
4648
cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2),
4749
cl::Hidden);
4850

51+
cl::opt<unsigned> TailDupIndirectBranchSize(
52+
"tail-dup-indirect-size",
53+
cl::desc("Maximum instructions to consider tail duplicating blocks that "
54+
"end with indirect branches."), cl::init(20),
55+
cl::Hidden);
56+
4957
static cl::opt<bool>
5058
TailDupVerify("tail-dup-verify",
5159
cl::desc("Verify sanity of PHI instructions during taildup"),
@@ -54,8 +62,6 @@ static cl::opt<bool>
5462
static cl::opt<unsigned> TailDupLimit("tail-dup-limit", cl::init(~0U),
5563
cl::Hidden);
5664

57-
namespace llvm {
58-
5965
void TailDuplicator::initMF(MachineFunction &MFin,
6066
const MachineBranchProbabilityInfo *MBPIin,
6167
unsigned TailDupSizeIn) {
@@ -550,7 +556,7 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple,
550556
HasIndirectbr = TailBB.back().isIndirectBranch();
551557

552558
if (HasIndirectbr && PreRegAlloc)
553-
MaxDuplicateCount = 20;
559+
MaxDuplicateCount = TailDupIndirectBranchSize;
554560

555561
// Check the instructions in the block to determine whether tail-duplication
556562
// is invalid or unlikely to be profitable.

0 commit comments

Comments
 (0)