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
This commit is contained in:
Duncan Sands 2008-04-13 16:04:03 +00:00
parent c0cb28fd3a
commit 4a6da60787
2 changed files with 51 additions and 0 deletions

View 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) {

View 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.