mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 11:51:13 +00:00
[MSSA] Add domination number verifier; NFC
It's easy for domination numbers to get out-of-date, and this is no more costly than any of the other verifiers we already have, so it seems nice to have. A stage3 build with this Works On My Machine, so this hasn't caught any bugs... yet. :) llvm-svn: 335444
This commit is contained in:
parent
044139ce11
commit
f1d92a8894
@ -722,6 +722,7 @@ protected:
|
||||
void verifyDefUses(Function &F) const;
|
||||
void verifyDomination(Function &F) const;
|
||||
void verifyOrdering(Function &F) const;
|
||||
void verifyDominationNumbers(const Function &F) const;
|
||||
|
||||
// This is used by the use optimizer and updater.
|
||||
AccessList *getWritableBlockAccesses(const BasicBlock *BB) const {
|
||||
|
@ -1633,9 +1633,48 @@ void MemorySSA::verifyMemorySSA() const {
|
||||
verifyDefUses(F);
|
||||
verifyDomination(F);
|
||||
verifyOrdering(F);
|
||||
verifyDominationNumbers(F);
|
||||
Walker->verify(this);
|
||||
}
|
||||
|
||||
/// Verify that all of the blocks we believe to have valid domination numbers
|
||||
/// actually have valid domination numbers.
|
||||
void MemorySSA::verifyDominationNumbers(const Function &F) const {
|
||||
#ifndef NDEBUG
|
||||
if (BlockNumberingValid.empty())
|
||||
return;
|
||||
|
||||
SmallPtrSet<const BasicBlock *, 16> ValidBlocks = BlockNumberingValid;
|
||||
for (const BasicBlock &BB : F) {
|
||||
if (!ValidBlocks.count(&BB))
|
||||
continue;
|
||||
|
||||
ValidBlocks.erase(&BB);
|
||||
|
||||
const AccessList *Accesses = getBlockAccesses(&BB);
|
||||
// It's correct to say an empty block has valid numbering.
|
||||
if (!Accesses)
|
||||
continue;
|
||||
|
||||
// Block numbering starts at 1.
|
||||
unsigned long LastNumber = 0;
|
||||
for (const MemoryAccess &MA : *Accesses) {
|
||||
auto ThisNumberIter = BlockNumbering.find(&MA);
|
||||
assert(ThisNumberIter != BlockNumbering.end() &&
|
||||
"MemoryAccess has no domination number in a valid block!");
|
||||
|
||||
unsigned long ThisNumber = ThisNumberIter->second;
|
||||
assert(ThisNumber > LastNumber &&
|
||||
"Domination numbers should be strictly increasing!");
|
||||
LastNumber = ThisNumber;
|
||||
}
|
||||
}
|
||||
|
||||
assert(ValidBlocks.empty() &&
|
||||
"All valid BasicBlocks should exist in F -- dangling pointers?");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Verify that the order and existence of MemoryAccesses matches the
|
||||
/// order and existence of memory affecting instructions.
|
||||
void MemorySSA::verifyOrdering(Function &F) const {
|
||||
|
Loading…
Reference in New Issue
Block a user