LegalizeTypes can sometimes have deleted nodes
authorDuncan Sands <baldrick@free.fr>
Sun, 13 Apr 2008 16:04:03 +0000 (16:04 +0000)
committerDuncan Sands <baldrick@free.fr>
Sun, 13 Apr 2008 16:04:03 +0000 (16:04 +0000)
in its maps.  Add some sanity checks that catch
this kind of thing.  Hopefully these can be
removed one day (once all problems are fixed!)
but for the moment it seems wise to have them in.

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

lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h

index 380c42220c7548d18e374598856480e66ef84f4b..34f99da49fa7f074542d77d93da6af391b45ad57 100644 (file)
@@ -267,6 +267,51 @@ void DAGTypeLegalizer::AnalyzeNewNode(SDNode *&N) {
     Worklist.push_back(N);
 }
 
+void DAGTypeLegalizer::SanityCheck(SDNode *N) {
+  for (SmallVector<SDNode*, 128>::iterator I = Worklist.begin(),
+       E = Worklist.end(); I != E; ++I)
+    assert(*I != N);
+
+  for (DenseMap<SDOperandImpl, SDOperand>::iterator I = ReplacedNodes.begin(),
+       E = ReplacedNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.Val != N);
+  }
+
+  for (DenseMap<SDOperandImpl, SDOperand>::iterator I = PromotedNodes.begin(),
+       E = PromotedNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.Val != N);
+  }
+
+  for (DenseMap<SDOperandImpl, SDOperand>::iterator
+       I = FloatToIntedNodes.begin(),
+       E = FloatToIntedNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.Val != N);
+  }
+
+  for (DenseMap<SDOperandImpl, SDOperand>::iterator I = ScalarizedNodes.begin(),
+       E = ScalarizedNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.Val != N);
+  }
+
+  for (DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> >::iterator
+       I = ExpandedNodes.begin(), E = ExpandedNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.first.Val != N);
+    assert(I->second.second.Val != N);
+  }
+
+  for (DenseMap<SDOperandImpl, std::pair<SDOperand, SDOperand> >::iterator
+       I = SplitNodes.begin(), E = SplitNodes.end(); I != E; ++I) {
+    assert(I->first.Val != N);
+    assert(I->second.first.Val != N);
+    assert(I->second.second.Val != N);
+  }
+}
+
 namespace {
   /// NodeUpdateListener - This class is a DAGUpdateListener that listens for
   /// updates to nodes and recomputes their ready state.
@@ -281,6 +326,9 @@ namespace {
       assert(N->getNodeId() != DAGTypeLegalizer::Processed &&
              N->getNodeId() != DAGTypeLegalizer::ReadyToProcess &&
              "RAUW deleted processed node!");
+#ifndef NDEBUG
+      DTL.SanityCheck(N);
+#endif
     }
 
     virtual void NodeUpdated(SDNode *N) {
index 5b9879315f8e07d5344cbc20b328cd556c2b217c..b5ec7d1ca8eb9cc5fe32a60324cc04cb5cba91c8 100644 (file)
@@ -379,6 +379,9 @@ private:
   SDOperand SplitOp_RET(SDNode *N, unsigned OpNo);
   SDOperand SplitOp_STORE(StoreSDNode *N, unsigned OpNo);
   SDOperand SplitOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo);
+
+public:
+  void SanityCheck(SDNode *N);
 };
 
 } // end namespace llvm.