aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
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
commit9450b0e1a6154192ca597ad27f8eb6e6e807f7a4 (patch)
tree30b9306c15136bcce40db9d6de99e2ce201f581a /lib/VMCore
parentf3f0c89f5f9c2ad99169084cbfedaf3ed0ee6a50 (diff)
downloadexternal_llvm-9450b0e1a6154192ca597ad27f8eb6e6e807f7a4.zip
external_llvm-9450b0e1a6154192ca597ad27f8eb6e6e807f7a4.tar.gz
external_llvm-9450b0e1a6154192ca597ad27f8eb6e6e807f7a4.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Dominators.cpp32
-rw-r--r--lib/VMCore/PassManager.cpp61
2 files changed, 39 insertions, 54 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index 1f17214..40e4c4b 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/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) {
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index a3496ed..f10bc6f 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -13,6 +13,7 @@
#include "llvm/PassManagers.h"
+#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Timer.h"
#include "llvm/Module.h"
@@ -22,7 +23,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Mutex.h"
#include "llvm/System/Threading.h"
-#include "llvm/Analysis/Dominators.h"
#include "llvm-c/Core.h"
#include <algorithm>
#include <cstdio>
@@ -45,16 +45,6 @@ enum PassDebugLevel {
None, Arguments, Structure, Executions, Details
};
-// 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)"));
-
static cl::opt<enum PassDebugLevel>
PassDebugging("debug-pass", cl::Hidden,
cl::desc("Print PassManager debugging information"),
@@ -703,47 +693,13 @@ void PMDataManager::verifyPreservedAnalysis(Pass *P) {
for (AnalysisUsage::VectorType::const_iterator I = PreservedSet.begin(),
E = PreservedSet.end(); I != E; ++I) {
AnalysisID AID = *I;
- if (Pass *AP = findAnalysisPass(AID, true))
- AP->verifyAnalysis();
- }
-}
-
-/// verifyDomInfo - Verify dominator information if it is available.
-void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
- if (!VerifyDomInfo || !P.getResolver())
- return;
+ if (Pass *AP = findAnalysisPass(AID, true)) {
- DominatorTree *DT = P.getAnalysisIfAvailable<DominatorTree>();
- if (!DT)
- return;
-
- DominatorTree OtherDT;
- OtherDT.getBase().recalculate(F);
- if (DT->compare(OtherDT)) {
- errs() << "Dominator Information for " << F.getName() << "\n";
- errs() << "Pass '" << P.getPassName() << "'\n";
- errs() << "----- Valid -----\n";
- OtherDT.dump();
- errs() << "----- Invalid -----\n";
- DT->dump();
- llvm_unreachable("Invalid dominator info");
- }
-
- DominanceFrontier *DF = P.getAnalysisIfAvailable<DominanceFrontier>();
- if (!DF)
- return;
-
- DominanceFrontier OtherDF;
- std::vector<BasicBlock*> DTRoots = DT->getRoots();
- OtherDF.calculate(*DT, DT->getNode(DTRoots[0]));
- if (DF->compare(OtherDF)) {
- errs() << "Dominator Information for " << F.getName() << "\n";
- errs() << "Pass '" << P.getPassName() << "'\n";
- errs() << "----- Valid -----\n";
- OtherDF.dump();
- errs() << "----- Invalid -----\n";
- DF->dump();
- llvm_unreachable("Invalid dominator info");
+ Timer *T = 0;
+ if (TheTimeInfo) T = TheTimeInfo->passStarted(AP);
+ AP->verifyAnalysis();
+ if (T) T->stopTimer();
+ }
}
}
@@ -1384,9 +1340,6 @@ bool FPPassManager::runOnFunction(Function &F) {
removeNotPreservedAnalysis(FP);
recordAvailableAnalysis(FP);
removeDeadPasses(FP, F.getName(), ON_FUNCTION_MSG);
-
- // If dominator information is available then verify the info if requested.
- verifyDomInfo(*FP, F);
}
return Changed;
}