[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Feb 19 22:51:16 PST 2006
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.108 -> 1.109
---
Log message:
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.
---
Diffs of the changes: (+8 -4)
DAGCombiner.cpp | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.108 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.109
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.108 Fri Feb 17 20:40:58 2006
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Feb 20 00:51:04 2006
@@ -120,18 +120,22 @@
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;
}
More information about the llvm-commits
mailing list