don't add nodes to the now-dead nodes list multiple times, this
authorChris Lattner <sabre@nondot.org>
Sun, 28 Mar 2010 05:28:31 +0000 (05:28 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 28 Mar 2010 05:28:31 +0000 (05:28 +0000)
can cause a crash on crazy situations in msp430 when morph-node-to
is disabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99739 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 600557eddfdd20ddb071edb78cf3417132b31cac..3981826f59aa1f8ab112e34558b0f227b962c4ef 100644 (file)
@@ -1592,8 +1592,9 @@ UpdateChainsAndFlags(SDNode *NodeToMatch, SDValue InputChain,
       assert(ChainVal.getValueType() == MVT::Other && "Not a chain?");
       CurDAG->ReplaceAllUsesOfValueWith(ChainVal, InputChain, &ISU);
       
-      // If the node became dead, delete it.
-      if (ChainNode->use_empty())
+      // If the node became dead and we haven't already seen it, delete it.
+      if (ChainNode->use_empty() &&
+          !std::count(NowDeadNodes.begin(), NowDeadNodes.end(), ChainNode))
         NowDeadNodes.push_back(ChainNode);
     }
   }