mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
replace a slow and verbose version of Instruction::isUsedOutsideOfBlock with
a call to Instruction::isUsedOutsideOfBlock. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7ae40e7d8a
commit
0cfe85be0b
@ -264,40 +264,10 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
|
|||||||
// this reason, we spill all values that are used outside of the tail to the
|
// this reason, we spill all values that are used outside of the tail to the
|
||||||
// stack.
|
// stack.
|
||||||
for (BasicBlock::iterator I = DestBlock->begin(); I != DestBlock->end(); ++I)
|
for (BasicBlock::iterator I = DestBlock->begin(); I != DestBlock->end(); ++I)
|
||||||
for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
|
if (I->isUsedOutsideOfBlock(DestBlock)) {
|
||||||
++UI) {
|
|
||||||
bool ShouldDemote = false;
|
|
||||||
if (cast<Instruction>(*UI)->getParent() != DestBlock) {
|
|
||||||
// We must allow our successors to use tail values in their PHI nodes
|
|
||||||
// (if the incoming value corresponds to the tail block).
|
|
||||||
if (PHINode *PN = dyn_cast<PHINode>(*UI)) {
|
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
|
||||||
if (PN->getIncomingValue(i) == I &&
|
|
||||||
PN->getIncomingBlock(i) != DestBlock) {
|
|
||||||
ShouldDemote = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ShouldDemote = true;
|
|
||||||
}
|
|
||||||
} else if (PHINode *PN = dyn_cast<PHINode>(cast<Instruction>(*UI))) {
|
|
||||||
// If the user of this instruction is a PHI node in the current block,
|
|
||||||
// which has an entry from another block using the value, spill it.
|
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
|
||||||
if (PN->getIncomingValue(i) == I &&
|
|
||||||
PN->getIncomingBlock(i) != DestBlock) {
|
|
||||||
ShouldDemote = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ShouldDemote) {
|
|
||||||
// We found a use outside of the tail. Create a new stack slot to
|
// We found a use outside of the tail. Create a new stack slot to
|
||||||
// break this inter-block usage pattern.
|
// break this inter-block usage pattern.
|
||||||
DemoteRegToStack(*I);
|
DemoteRegToStack(*I);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are going to have to map operands from the original block B to the new
|
// We are going to have to map operands from the original block B to the new
|
||||||
|
Loading…
Reference in New Issue
Block a user