From 4a6da60787fcc66c521288fbd139cf8afdca5957 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Sun, 13 Apr 2008 16:04:03 +0000 Subject: [PATCH] LegalizeTypes can sometimes have deleted nodes 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 | 48 ++++++++++++++++++++++ lib/CodeGen/SelectionDAG/LegalizeTypes.h | 3 ++ 2 files changed, 51 insertions(+) diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 380c42220c7..34f99da49fa 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -267,6 +267,51 @@ void DAGTypeLegalizer::AnalyzeNewNode(SDNode *&N) { Worklist.push_back(N); } +void DAGTypeLegalizer::SanityCheck(SDNode *N) { + for (SmallVector::iterator I = Worklist.begin(), + E = Worklist.end(); I != E; ++I) + assert(*I != N); + + for (DenseMap::iterator I = ReplacedNodes.begin(), + E = ReplacedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator I = PromotedNodes.begin(), + E = PromotedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator + I = FloatToIntedNodes.begin(), + E = FloatToIntedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap::iterator I = ScalarizedNodes.begin(), + E = ScalarizedNodes.end(); I != E; ++I) { + assert(I->first.Val != N); + assert(I->second.Val != N); + } + + for (DenseMap >::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 >::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) { diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h index 5b9879315f8..b5ec7d1ca8e 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -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.