diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-01-07 23:32:00 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-01-07 23:32:00 +0000 | 
| commit | e0f1fe181aa808263d6e196aa3b51e796179db94 (patch) | |
| tree | 0173b6ad10355f938b176c7bce418eb2f84afe29 | |
| parent | 5c66e45b9218fc9abbcbffcc81a8f04365ae4d50 (diff) | |
| download | bcm5719-llvm-e0f1fe181aa808263d6e196aa3b51e796179db94.tar.gz bcm5719-llvm-e0f1fe181aa808263d6e196aa3b51e796179db94.zip | |
Fix a pointer invalidation problem.  This fixes Generic/badarg6.ll
llvm-svn: 19361
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 20 | 
1 files changed, 7 insertions, 13 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index e917350f8c9..357275eb244 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -191,29 +191,22 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {    }    // Next, brutally remove the operand list. -  std::vector<SDNode*> Operands;    while (!N->Operands.empty()) { -    SDOperand O = N->Operands.back(); +    SDNode *O = N->Operands.back().Val;      N->Operands.pop_back(); -    Operands.push_back(O.Val); -    O.Val->removeUser(N); +    O->removeUser(N); + +    // Now that we removed this operand, see if there are no uses of it left. +    DeleteNodeIfDead(O, NodeSet);    }    // Remove the node from the nodes set and delete it.    std::set<SDNode*> &AllNodeSet = *(std::set<SDNode*>*)NodeSet;    AllNodeSet.erase(N); -  delete N;    // Now that the node is gone, check to see if any of the operands of this node    // are dead now. - -  // Remove duplicate operand entries. -  std::sort(Operands.begin(), Operands.end()); -  Operands.erase(std::unique(Operands.begin(), Operands.end()), -                 Operands.end()); -   -  for (unsigned i = 0, e = Operands.size(); i != e; ++i) -    DeleteNodeIfDead(Operands[i], NodeSet); +  delete N;  } @@ -733,6 +726,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT,          return getNode(ISD::BR, MVT::Other, N1, N3);        else          return N1;         // Never-taken branch +    break;    }    SDNode *N = new SDNode(Opcode, N1, N2, N3); | 

