diff options
| author | Bill Wendling <isanbard@gmail.com> | 2008-12-22 21:36:08 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2008-12-22 21:36:08 +0000 |
| commit | 6b18a3994bc05a7f47fd92bf02ecdfa231d26ef5 (patch) | |
| tree | 6dbebfd127183b25bcf8605495836d47fc8b83f2 /llvm/lib/Transforms/Scalar/GVN.cpp | |
| parent | 9b244a8797ebcc5d315246d90a74fed432a6972b (diff) | |
| download | bcm5719-llvm-6b18a3994bc05a7f47fd92bf02ecdfa231d26ef5.tar.gz bcm5719-llvm-6b18a3994bc05a7f47fd92bf02ecdfa231d26ef5.zip | |
Add verification functions to GVN which check to see that an instruction was
truely deleted. These will be expanded with further checks of all of the data
structures.
llvm-svn: 61347
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVN.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 6e532630c7b..8a3b384b063 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -173,6 +173,7 @@ namespace { void setMemDep(MemoryDependenceAnalysis* M) { MD = M; } void setDomTree(DominatorTree* D) { DT = D; } uint32_t getNextUnusedValueNumber() { return nextValueNumber; } + void verifyRemoved(const Value *) const; }; } @@ -678,6 +679,15 @@ void ValueTable::erase(Value* V) { valueNumbering.erase(V); } +/// verifyRemoved - Verify that the value is removed from all internal data +/// structures. +void ValueTable::verifyRemoved(const Value *V) const { + for (DenseMap<Value*, uint32_t>::iterator + I = valueNumbering.begin(), E = valueNumbering.end(); I != E; ++I) { + assert(I->first != V && "Inst still occurs in value numbering map!"); + } +} + //===----------------------------------------------------------------------===// // GVN Pass //===----------------------------------------------------------------------===// @@ -741,6 +751,7 @@ namespace { bool mergeBlockIntoPredecessor(BasicBlock* BB); Value* AttemptRedundancyElimination(Instruction* orig, unsigned valno); void cleanupGlobalSets(); + void verifyRemoved(const Instruction *I) const; }; char GVN::ID = 0; @@ -859,6 +870,7 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig, DEBUG(cerr << "GVN removed: " << *PN); MD->removeInstruction(PN); PN->eraseFromParent(); + DEBUG(verifyRemoved(PN)); Phis[BB] = v; return v; @@ -1640,3 +1652,9 @@ void GVN::cleanupGlobalSets() { delete I->second; localAvail.clear(); } + +/// verifyRemoved - Verify that the specified instruction does not occur in our +/// internal data structures. +void GVN::verifyRemoved(const Instruction *I) const { + VN.verifyRemoved(I); +} |

