mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
refactor some code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -57,6 +57,8 @@ namespace {
|
|||||||
bool runOnFunction(Function &F);
|
bool runOnFunction(Function &F);
|
||||||
bool ThreadBlock(BasicBlock *BB);
|
bool ThreadBlock(BasicBlock *BB);
|
||||||
void ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB);
|
void ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, BasicBlock *SuccBB);
|
||||||
|
|
||||||
|
bool ProcessJumpOnPHI(PHINode *PN);
|
||||||
};
|
};
|
||||||
char JumpThreading::ID = 0;
|
char JumpThreading::ID = 0;
|
||||||
RegisterPass<JumpThreading> X("jump-threading", "Jump Threading");
|
RegisterPass<JumpThreading> X("jump-threading", "Jump Threading");
|
||||||
@ -158,8 +160,17 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
|
|||||||
|
|
||||||
// See if this is a phi node in the current block.
|
// See if this is a phi node in the current block.
|
||||||
PHINode *PN = dyn_cast<PHINode>(Condition);
|
PHINode *PN = dyn_cast<PHINode>(Condition);
|
||||||
if (!PN || PN->getParent() != BB) return false;
|
if (PN && PN->getParent() == BB)
|
||||||
|
return ProcessJumpOnPHI(PN);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ProcessJumpOnPHI - We have a conditional branch of switch on a PHI node in
|
||||||
|
/// the current block. See if there are any simplifications we can do based on
|
||||||
|
/// inputs to the phi node.
|
||||||
|
///
|
||||||
|
bool JumpThreading::ProcessJumpOnPHI(PHINode *PN) {
|
||||||
// See if the phi node has any constant values. If so, we can determine where
|
// See if the phi node has any constant values. If so, we can determine where
|
||||||
// the corresponding predecessor will branch.
|
// the corresponding predecessor will branch.
|
||||||
unsigned PredNo = ~0U;
|
unsigned PredNo = ~0U;
|
||||||
@ -177,6 +188,7 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// See if the cost of duplicating this block is low enough.
|
// See if the cost of duplicating this block is low enough.
|
||||||
|
BasicBlock *BB = PN->getParent();
|
||||||
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
unsigned JumpThreadCost = getJumpThreadDuplicationCost(BB);
|
||||||
if (JumpThreadCost > Threshold) {
|
if (JumpThreadCost > Threshold) {
|
||||||
DOUT << " Not threading BB '" << BB->getNameStart()
|
DOUT << " Not threading BB '" << BB->getNameStart()
|
||||||
@ -210,7 +222,6 @@ bool JumpThreading::ThreadBlock(BasicBlock *BB) {
|
|||||||
".thr_comm", this);
|
".thr_comm", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DOUT << " Threading edge from '" << PredBB->getNameStart() << "' to '"
|
DOUT << " Threading edge from '" << PredBB->getNameStart() << "' to '"
|
||||||
<< SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
|
<< SuccBB->getNameStart() << "' with cost: " << JumpThreadCost
|
||||||
<< ", across block:\n "
|
<< ", across block:\n "
|
||||||
|
Reference in New Issue
Block a user