diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-06-24 13:32:22 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-06-24 13:32:22 +0000 |
commit | fd342808e0b57e632c7a85c6bbd8bae06a4a2be9 (patch) | |
tree | 1f20f0455825fd060465db347af55e11b5eb8c67 /llvm/lib/CodeGen/MachineDominators.cpp | |
parent | f092cc8a14191801e9fa7abc3eb980dfbb731564 (diff) | |
download | bcm5719-llvm-fd342808e0b57e632c7a85c6bbd8bae06a4a2be9.tar.gz bcm5719-llvm-fd342808e0b57e632c7a85c6bbd8bae06a4a2be9.zip |
[MachineDominatorTree] Add a MDT verifier.
Differential Revision: http://reviews.llvm.org/D21657
llvm-svn: 273678
Diffstat (limited to 'llvm/lib/CodeGen/MachineDominators.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineDominators.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineDominators.cpp b/llvm/lib/CodeGen/MachineDominators.cpp index 3f04bb0b532..be6778ac17a 100644 --- a/llvm/lib/CodeGen/MachineDominators.cpp +++ b/llvm/lib/CodeGen/MachineDominators.cpp @@ -15,9 +15,20 @@ #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/Passes.h" #include "llvm/ADT/SmallBitVector.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; +// FIXME: Always verify dominfo if expensive checking is enabled. +#ifdef EXPENSIVE_CHECKS +static bool VerifyMachineDomInfo = false; +#else +static bool VerifyMachineDomInfo = false; +#endif +static cl::opt<bool, true> VerifyMachineDomInfoX( + "verify-machine-dom-info", cl::location(VerifyMachineDomInfo), + cl::desc("Verify machine dominator info (time consuming)")); + namespace llvm { template class DomTreeNodeBase<MachineBasicBlock>; template class DominatorTreeBase<MachineBasicBlock>; @@ -57,6 +68,11 @@ void MachineDominatorTree::releaseMemory() { DT->releaseMemory(); } +void MachineDominatorTree::verifyAnalysis() const { + if (VerifyMachineDomInfo) + verifyDomTree(); +} + void MachineDominatorTree::print(raw_ostream &OS, const Module*) const { DT->print(OS); } @@ -125,3 +141,17 @@ void MachineDominatorTree::applySplitCriticalEdges() const { NewBBs.clear(); CriticalEdgesToSplit.clear(); } + +void MachineDominatorTree::verifyDomTree() const { + MachineFunction &F = *getRoot()->getParent(); + + MachineDominatorTree OtherDT; + OtherDT.DT->recalculate(F); + if (compare(OtherDT)) { + errs() << "MachineDominatorTree is not up to date!\nComputed:\n"; + print(errs(), nullptr); + errs() << "\nActual:\n"; + OtherDT.print(errs(), nullptr); + abort(); + } +} |