mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
Allow BB duplication threshold to be adjusted through JumpThreading's ctor
- BB duplication may not be desired on targets where there is no or small branch penalty and code duplication needs restrict control. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218375 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bfb2b180bf
commit
35fdc092e0
@ -206,9 +206,10 @@ FunctionPass *createReassociatePass();
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
|
// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
|
||||||
// preds always go to some succ.
|
// preds always go to some succ. Thresholds other than minus one override the
|
||||||
|
// internal BB duplication default threshold.
|
||||||
//
|
//
|
||||||
FunctionPass *createJumpThreadingPass();
|
FunctionPass *createJumpThreadingPass(int Threshold = -1);
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
|
@ -45,7 +45,7 @@ STATISTIC(NumFolds, "Number of terminators folded");
|
|||||||
STATISTIC(NumDupes, "Number of branch blocks duplicated to eliminate phi");
|
STATISTIC(NumDupes, "Number of branch blocks duplicated to eliminate phi");
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned>
|
||||||
Threshold("jump-threading-threshold",
|
BBDuplicateThreshold("jump-threading-threshold",
|
||||||
cl::desc("Max block size to duplicate for jump threading"),
|
cl::desc("Max block size to duplicate for jump threading"),
|
||||||
cl::init(6), cl::Hidden);
|
cl::init(6), cl::Hidden);
|
||||||
|
|
||||||
@ -88,6 +88,8 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
DenseSet<std::pair<Value*, BasicBlock*> > RecursionSet;
|
DenseSet<std::pair<Value*, BasicBlock*> > RecursionSet;
|
||||||
|
|
||||||
|
unsigned BBDupThreshold;
|
||||||
|
|
||||||
// RAII helper for updating the recursion stack.
|
// RAII helper for updating the recursion stack.
|
||||||
struct RecursionSetRemover {
|
struct RecursionSetRemover {
|
||||||
DenseSet<std::pair<Value*, BasicBlock*> > &TheSet;
|
DenseSet<std::pair<Value*, BasicBlock*> > &TheSet;
|
||||||
@ -103,7 +105,8 @@ namespace {
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification
|
static char ID; // Pass identification
|
||||||
JumpThreading() : FunctionPass(ID) {
|
JumpThreading(int T = -1) : FunctionPass(ID) {
|
||||||
|
BBDupThreshold = (T == -1) ? BBDuplicateThreshold : unsigned(T);
|
||||||
initializeJumpThreadingPass(*PassRegistry::getPassRegistry());
|
initializeJumpThreadingPass(*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +150,7 @@ INITIALIZE_PASS_END(JumpThreading, "jump-threading",
|
|||||||
"Jump Threading", false, false)
|
"Jump Threading", false, false)
|
||||||
|
|
||||||
// Public interface to the Jump Threading pass
|
// Public interface to the Jump Threading pass
|
||||||
FunctionPass *llvm::createJumpThreadingPass() { return new JumpThreading(); }
|
FunctionPass *llvm::createJumpThreadingPass(int Threshold) { return new JumpThreading(Threshold); }
|
||||||
|
|
||||||
/// runOnFunction - Top level algorithm.
|
/// runOnFunction - Top level algorithm.
|
||||||
///
|
///
|
||||||
@ -1389,8 +1392,8 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB, Threshold);
|
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB, BBDupThreshold);
|
||||||
if (JumpThreadCost > Threshold) {
|
if (JumpThreadCost > BBDupThreshold) {
|
||||||
DEBUG(dbgs() << " Not threading BB '" << BB->getName()
|
DEBUG(dbgs() << " Not threading BB '" << BB->getName()
|
||||||
<< "' - Cost is too high: " << JumpThreadCost << "\n");
|
<< "' - Cost is too high: " << JumpThreadCost << "\n");
|
||||||
return false;
|
return false;
|
||||||
@ -1532,8 +1535,8 @@ bool JumpThreading::DuplicateCondBranchOnPHIIntoPred(BasicBlock *BB,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB, Threshold);
|
unsigned DuplicationCost = getJumpThreadDuplicationCost(BB, BBDupThreshold);
|
||||||
if (DuplicationCost > Threshold) {
|
if (DuplicationCost > BBDupThreshold) {
|
||||||
DEBUG(dbgs() << " Not duplicating BB '" << BB->getName()
|
DEBUG(dbgs() << " Not duplicating BB '" << BB->getName()
|
||||||
<< "' - Cost is too high: " << DuplicationCost << "\n");
|
<< "' - Cost is too high: " << DuplicationCost << "\n");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user