summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Dominators.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-28 00:27:48 +0000
committerDan Gohman <gohman@apple.com>2009-09-28 00:27:48 +0000
commit4dbb301f1760be643f6ddbf19abab706b385626a (patch)
tree18a5336ef984565f8a1a066e938147e87bbd4135 /llvm/lib/VMCore/Dominators.cpp
parent2963777d0cfe1936d4816c603e520b4afc176bd5 (diff)
downloadbcm5719-llvm-4dbb301f1760be643f6ddbf19abab706b385626a.tar.gz
bcm5719-llvm-4dbb301f1760be643f6ddbf19abab706b385626a.zip
Move the dominator verification code out of special code embedded within
the PassManager code into a regular verifyAnalysis method. Also, reorganize loop verification. Make the LoopPass infrastructure call verifyLoop as needed instead of having LoopInfo::verifyAnalysis check every loop in the function after each looop pass. Add a new command-line argument, -verify-loop-info, to enable the expensive full checking. llvm-svn: 82952
Diffstat (limited to 'llvm/lib/VMCore/Dominators.cpp')
-rw-r--r--llvm/lib/VMCore/Dominators.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp
index 1f172145c3b..40e4c4bc4c8 100644
--- a/llvm/lib/VMCore/Dominators.cpp
+++ b/llvm/lib/VMCore/Dominators.cpp
@@ -24,9 +24,20 @@
#include "llvm/Analysis/DominatorInternals.h"
#include "llvm/Instructions.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/CommandLine.h"
#include <algorithm>
using namespace llvm;
+// Always verify dominfo if expensive checking is enabled.
+#ifdef XDEBUG
+bool VerifyDomInfo = true;
+#else
+bool VerifyDomInfo = false;
+#endif
+static cl::opt<bool,true>
+VerifyDomInfoX("verify-dom-info", cl::location(VerifyDomInfo),
+ cl::desc("Verify dominator info (time consuming)"));
+
//===----------------------------------------------------------------------===//
// DominatorTree Implementation
//===----------------------------------------------------------------------===//
@@ -48,6 +59,16 @@ bool DominatorTree::runOnFunction(Function &F) {
return false;
}
+void DominatorTree::verifyAnalysis() const {
+ if (!VerifyDomInfo || true /* fixme */) return;
+
+ Function &F = *getRoot()->getParent();
+
+ DominatorTree OtherDT;
+ OtherDT.getBase().recalculate(F);
+ assert(!compare(OtherDT) && "Invalid DominatorTree info!");
+}
+
void DominatorTree::print(raw_ostream &OS, const Module *) const {
DT->print(OS);
}
@@ -87,6 +108,17 @@ char DominanceFrontier::ID = 0;
static RegisterPass<DominanceFrontier>
G("domfrontier", "Dominance Frontier Construction", true, true);
+void DominanceFrontier::verifyAnalysis() const {
+ if (!VerifyDomInfo) return;
+
+ DominatorTree &DT = getAnalysis<DominatorTree>();
+
+ DominanceFrontier OtherDF;
+ const std::vector<BasicBlock*> &DTRoots = DT.getRoots();
+ OtherDF.calculate(DT, DT.getNode(DTRoots[0]));
+ assert(!compare(OtherDF) && "Invalid DominanceFrontier info!");
+}
+
// NewBB is split and now it has one successor. Update dominace frontier to
// reflect this change.
void DominanceFrontier::splitBlock(BasicBlock *NewBB) {
OpenPOWER on IntegriCloud