mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Rewrite SelectionDAG::isPredecessorOf to be iterative instead of
recursive to avoid consuming extraordinary amounts of stack space when processing tall graphs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85369 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -5307,31 +5307,26 @@ bool SDValue::reachesChainWithoutSideEffects(SDValue Dest,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void findPredecessor(SDNode *N, const SDNode *P, bool &found,
|
|
||||||
SmallPtrSet<SDNode *, 32> &Visited) {
|
|
||||||
if (found || !Visited.insert(N))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (unsigned i = 0, e = N->getNumOperands(); !found && i != e; ++i) {
|
|
||||||
SDNode *Op = N->getOperand(i).getNode();
|
|
||||||
if (Op == P) {
|
|
||||||
found = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
findPredecessor(Op, P, found, Visited);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isPredecessorOf - Return true if this node is a predecessor of N. This node
|
/// isPredecessorOf - Return true if this node is a predecessor of N. This node
|
||||||
/// is either an operand of N or it can be reached by recursively traversing
|
/// is either an operand of N or it can be reached by traversing up the operands.
|
||||||
/// up the operands.
|
|
||||||
/// NOTE: this is an expensive method. Use it carefully.
|
/// NOTE: this is an expensive method. Use it carefully.
|
||||||
bool SDNode::isPredecessorOf(SDNode *N) const {
|
bool SDNode::isPredecessorOf(SDNode *N) const {
|
||||||
SmallPtrSet<SDNode *, 32> Visited;
|
SmallPtrSet<SDNode *, 32> Visited;
|
||||||
bool found = false;
|
SmallVector<SDNode *, 16> Worklist;
|
||||||
findPredecessor(N, this, found, Visited);
|
Worklist.push_back(N);
|
||||||
return found;
|
|
||||||
|
do {
|
||||||
|
N = Worklist.pop_back_val();
|
||||||
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
||||||
|
SDNode *Op = N->getOperand(i).getNode();
|
||||||
|
if (Op == this)
|
||||||
|
return true;
|
||||||
|
if (Visited.insert(Op))
|
||||||
|
Worklist.push_back(Op);
|
||||||
|
}
|
||||||
|
} while (!Worklist.empty());
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t SDNode::getConstantOperandVal(unsigned Num) const {
|
uint64_t SDNode::getConstantOperandVal(unsigned Num) const {
|
||||||
|
Reference in New Issue
Block a user