summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-23 19:32:27 +0000
committerChris Lattner <sabre@nondot.org>2010-02-23 19:32:27 +0000
commitda244a091dcde022ea4938793d81ee957903ed70 (patch)
tree4344901b7152e234dc37366a79d944a71eb5a7eb /lib
parent4548e02bd6336983a21afdf5f6a3ea333ce2daca (diff)
downloadllvm-da244a091dcde022ea4938793d81ee957903ed70.tar.gz
llvm-da244a091dcde022ea4938793d81ee957903ed70.tar.bz2
llvm-da244a091dcde022ea4938793d81ee957903ed70.tar.xz
fix a bug in findNonImmUse (used by IsLegalToFold) where nodes with
no id's would cause early exit allowing IsLegalToFold to return true instead of false, producing a cyclic dag. This was striking the new isel because it isn't using SelectNodeTo yet, which theoretically is just an optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96972 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 9ba0d55b7a..130299adf7 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1318,8 +1318,20 @@ static SDNode *findFlagUse(SDNode *N) {
static bool findNonImmUse(SDNode *Use, SDNode* Def, SDNode *ImmedUse,
SDNode *Root,
SmallPtrSet<SDNode*, 16> &Visited) {
- if (Use->getNodeId() < Def->getNodeId() ||
- !Visited.insert(Use))
+ // The NodeID's are given uniques ID's where a node ID is guaranteed to be
+ // greater than all of its (recursive) operands. If we scan to a point where
+ // 'use' is smaller than the node we're scanning for, then we know we will
+ // never find it.
+ //
+ // The Use may be -1 (unassigned) if it is a newly allocated node. This can
+ // happen because we scan down to newly selected nodes in the case of flag
+ // uses.
+ if ((Use->getNodeId() < Def->getNodeId() && Use->getNodeId() != -1))
+ return false;
+
+ // Don't revisit nodes if we already scanned it and didn't fail, we know we
+ // won't fail if we scan it again.
+ if (!Visited.insert(Use))
return false;
for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {