aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-04-13 16:04:03 +0000
committerDuncan Sands <baldrick@free.fr>2008-04-13 16:04:03 +0000
commit4a6da60787fcc66c521288fbd139cf8afdca5957 (patch)
treeb21f83fd9fe3632e5bfadfb2fe725b9b5927c0ce
parentc0cb28fd3abee9a8b40856990e04f1af2f9bd7b8 (diff)
downloadexternal_llvm-4a6da60787fcc66c521288fbd139cf8afdca5957.zip
external_llvm-4a6da60787fcc66c521288fbd139cf8afdca5957.tar.gz
external_llvm-4a6da60787fcc66c521288fbd139cf8afdca5957.tar.bz2
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
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp48
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.h3
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 380c422..34f99da 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<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) {
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/lib/CodeGen/SelectionDAG/LegalizeTypes.h
index 5b98793..b5ec7d1 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.