[llvm-branch-commits] [llvm-branch] r93033 - /llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Evan Cheng
evan.cheng at apple.com
Fri Jan 8 16:48:25 PST 2010
Author: evancheng
Date: Fri Jan 8 18:48:25 2010
New Revision: 93033
URL: http://llvm.org/viewvc/llvm-project?rev=93033&view=rev
Log:
Merge 93031.
Modified:
llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93033&r1=93032&r2=93033&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jan 8 18:48:25 2010
@@ -424,6 +424,25 @@
SDL->clear();
}
+namespace {
+/// WorkListRemover - This class is a DAGUpdateListener that removes any deleted
+/// nodes from the worklist.
+class SDOPsWorkListRemover : public SelectionDAG::DAGUpdateListener {
+ SmallVector<SDNode*, 128> &Worklist;
+public:
+ SDOPsWorkListRemover(SmallVector<SDNode*, 128> &wl) : Worklist(wl) {}
+
+ virtual void NodeDeleted(SDNode *N, SDNode *E) {
+ Worklist.erase(std::remove(Worklist.begin(), Worklist.end(), N),
+ Worklist.end());
+ }
+
+ virtual void NodeUpdated(SDNode *N) {
+ // Ignore updates.
+ }
+};
+}
+
/// ShrinkDemandedOps - A late transformation pass that shrink expressions
/// using TargetLowering::TargetLoweringOpt::ShrinkDemandedOp. It converts
/// x+y to (VT)((SmallVT)x+(SmallVT)y) if the casts are free.
@@ -446,8 +465,7 @@
Worklist.pop_back();
if (N->use_empty() && N != CurDAG->getRoot().getNode()) {
- if (N->getOpcode() != ISD::DELETED_NODE)
- CurDAG->DeleteNode(N);
+ CurDAG->DeleteNode(N);
continue;
}
@@ -473,7 +491,9 @@
errs() << '\n');
Worklist.push_back(TLO.New.getNode());
- CurDAG->ReplaceAllUsesOfValueWith(TLO.Old, TLO.New);
+
+ SDOPsWorkListRemover DeadNodes(Worklist);
+ CurDAG->ReplaceAllUsesOfValueWith(TLO.Old, TLO.New, &DeadNodes);
if (TLO.Old.getNode()->use_empty()) {
for (unsigned i = 0, e = TLO.Old.getNode()->getNumOperands();
@@ -481,15 +501,13 @@
SDNode *OpNode = TLO.Old.getNode()->getOperand(i).getNode();
if (OpNode->hasOneUse()) {
Worklist.erase(std::remove(Worklist.begin(), Worklist.end(),
- OpNode),
- Worklist.end());
- Worklist.push_back(TLO.Old.getNode()->getOperand(i).getNode());
+ OpNode), Worklist.end());
+ Worklist.push_back(OpNode);
}
}
Worklist.erase(std::remove(Worklist.begin(), Worklist.end(),
- TLO.Old.getNode()),
- Worklist.end());
+ TLO.Old.getNode()), Worklist.end());
CurDAG->DeleteNode(TLO.Old.getNode());
}
}
More information about the llvm-branch-commits
mailing list