aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-01-19 21:44:21 +0000
committerDan Gohman <gohman@apple.com>2009-01-19 21:44:21 +0000
commitdbe664adcddd8610952968d86791478c874cf1cd (patch)
tree5d0f6b564ca7fc6a240dde912ad6e20b096def3f /lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent2c7ed11d93239dacf81540e2307f0db456bb9122 (diff)
Fix SelectionDAG::ReplaceAllUsesWith to behave correctly when
uses are added to the From node while it is processing From's use list, because of automatic local CSE. The fix is to avoid visiting any new uses. Fix a few places in the DAGCombiner that assumed that after a RAUW call, the From node has no users and may be deleted. This fixes PR3018. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 67a419aac9..0d90fc0748 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -522,12 +522,17 @@ SDValue DAGCombiner::CombineTo(SDNode *N, const SDValue *To, unsigned NumTo,
}
}
- // Nodes can be reintroduced into the worklist. Make sure we do not
- // process a node that has been replaced.
- removeFromWorkList(N);
+ // Finally, if the node is now dead, remove it from the graph. The node
+ // may not be dead if the replacement process recursively simplified to
+ // something else needing this node.
+ if (N->use_empty()) {
+ // Nodes can be reintroduced into the worklist. Make sure we do not
+ // process a node that has been replaced.
+ removeFromWorkList(N);
- // Finally, since the node is now dead, remove it from the graph.
- DAG.DeleteNode(N);
+ // Finally, since the node is now dead, remove it from the graph.
+ DAG.DeleteNode(N);
+ }
return SDValue(N, 0);
}
@@ -658,12 +663,17 @@ void DAGCombiner::Run(CombineLevel AtLevel) {
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
AddToWorkList(N->getOperand(i).getNode());
- // Nodes can be reintroduced into the worklist. Make sure we do not
- // process a node that has been replaced.
- removeFromWorkList(N);
+ // Finally, if the node is now dead, remove it from the graph. The node
+ // may not be dead if the replacement process recursively simplified to
+ // something else needing this node.
+ if (N->use_empty()) {
+ // Nodes can be reintroduced into the worklist. Make sure we do not
+ // process a node that has been replaced.
+ removeFromWorkList(N);
- // Finally, since the node is now dead, remove it from the graph.
- DAG.DeleteNode(N);
+ // Finally, since the node is now dead, remove it from the graph.
+ DAG.DeleteNode(N);
+ }
}
// If the root changed (e.g. it was a dead load, update the root).