[llvm-branch-commits] [llvm-branch] r85418 - /llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Bill Wendling
isanbard at gmail.com
Wed Oct 28 11:44:46 PDT 2009
Author: void
Date: Wed Oct 28 13:44:46 2009
New Revision: 85418
URL: http://llvm.org/viewvc/llvm-project?rev=85418&view=rev
Log:
$ svn merge -c 85369 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r85369 into '.':
U lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified:
llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Modified: llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=85418&r1=85417&r2=85418&view=diff
==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Oct 28 13:44:46 2009
@@ -5294,31 +5294,26 @@
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
-/// is either an operand of N or it can be reached by recursively traversing
-/// up the operands.
+/// is either an operand of N or it can be reached by traversing up the operands.
/// NOTE: this is an expensive method. Use it carefully.
bool SDNode::isPredecessorOf(SDNode *N) const {
SmallPtrSet<SDNode *, 32> Visited;
- bool found = false;
- findPredecessor(N, this, found, Visited);
- return found;
+ SmallVector<SDNode *, 16> Worklist;
+ Worklist.push_back(N);
+
+ 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 {
More information about the llvm-branch-commits
mailing list