summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-20 06:51:04 +0000
committerChris Lattner <sabre@nondot.org>2006-02-20 06:51:04 +0000
commit301f45cf6ffc429dd061c06ab7b4154fa5340398 (patch)
treecb15da9b12546277279527b37c80eb260d5ce5a2 /llvm/lib/CodeGen/SelectionDAG
parent486d1bc5edf05c2ebc930ca2d6eaa561e9813da5 (diff)
downloadbcm5719-llvm-301f45cf6ffc429dd061c06ab7b4154fa5340398.tar.gz
bcm5719-llvm-301f45cf6ffc429dd061c06ab7b4154fa5340398.zip
Fix a problem Nate and Duraid reported where simplifying nodes can cause
them to get ressurected, in which case, deleting the undead nodes is unfriendly. llvm-svn: 26291
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index bdb32ed78f4..ad09869d27b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -120,18 +120,22 @@ namespace {
std::vector<SDNode*> NowDead;
DAG.ReplaceAllUsesOfValueWith(TLO.Old, TLO.New, NowDead);
- // Push the new node and any (now) users onto the worklist.
+ // Push the new node and any (possibly new) users onto the worklist.
WorkList.push_back(TLO.New.Val);
AddUsersToWorkList(TLO.New.Val);
// Nodes can end up on the worklist more than once. Make sure we do
// not process a node that has been replaced.
- removeFromWorkList(TLO.Old.Val);
for (unsigned i = 0, e = NowDead.size(); i != e; ++i)
removeFromWorkList(NowDead[i]);
- // Finally, since the node is now dead, remove it from the graph.
- DAG.DeleteNode(TLO.Old.Val);
+ // 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 (TLO.Old.Val->use_empty()) {
+ removeFromWorkList(TLO.Old.Val);
+ DAG.DeleteNode(TLO.Old.Val);
+ }
return true;
}
OpenPOWER on IntegriCloud