aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-07-01 17:44:24 +0000
committerDevang Patel <dpatel@apple.com>2008-07-01 17:44:24 +0000
commit36a9bcebc1d3d9af63e361b9a0efb6def6441963 (patch)
treeaa121a5fcbffa87c52d49c76a7fc1c6e5c233fab /lib/VMCore
parent47aa4a410924b64dc2117b5e4cf7ac7cf3441a93 (diff)
downloadexternal_llvm-36a9bcebc1d3d9af63e361b9a0efb6def6441963.zip
external_llvm-36a9bcebc1d3d9af63e361b9a0efb6def6441963.tar.gz
external_llvm-36a9bcebc1d3d9af63e361b9a0efb6def6441963.tar.bz2
Add dom info verifier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/PassManager.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index e1f8afe..f98f2e1 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -19,6 +19,7 @@
#include "llvm/ModuleProvider.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Analysis/Dominators.h"
#include "llvm-c/Core.h"
#include <algorithm>
#include <vector>
@@ -41,6 +42,11 @@ enum PassDebugLevel {
None, Arguments, Structure, Executions, Details
};
+bool VerifyDomInfo = false;
+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"),
@@ -608,6 +614,46 @@ void PMDataManager::verifyPreservedAnalysis(Pass *P) {
}
}
+/// verifyDomInfo - Verify dominator information if it is available.
+void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
+
+ if (!VerifyDomInfo || !P.getResolver())
+ return;
+
+ DominatorTree *DT = P.getAnalysisToUpdate<DominatorTree>();
+ if (!DT)
+ return;
+
+ DominatorTree OtherDT;
+ OtherDT.getBase().recalculate(F);
+ if (DT->compare(OtherDT)) {
+ cerr << "Dominator Information for " << F.getNameStart() << "\n";
+ cerr << "Pass " << P.getPassName() << "\n";
+ cerr << "----- Valid -----\n";
+ OtherDT.dump();
+ cerr << "----- InValid -----\n";
+ DT->dump();
+ assert (0 && "Invalid dominator info");
+ }
+
+ DominanceFrontier *DF = P.getAnalysisToUpdate<DominanceFrontier>();
+ if (!DF)
+ return;
+
+ DominanceFrontier OtherDF;
+ std::vector<BasicBlock*> DTRoots = DT->getRoots();
+ OtherDF.calculate(*DT, DT->getNode(DTRoots[0]));
+ if (DF->compare(OtherDF)) {
+ cerr << "Dominator Information for " << F.getNameStart() << "\n";
+ cerr << "Pass " << P.getPassName() << "\n";
+ cerr << "----- Valid -----\n";
+ OtherDF.dump();
+ cerr << "----- InValid -----\n";
+ DF->dump();
+ assert (0 && "Invalid dominator info");
+ }
+}
+
/// Remove Analyss not preserved by Pass P
void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
AnalysisUsage AnUsage;
@@ -650,7 +696,6 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
InheritedAnalysis[Index]->erase(Info);
}
}
-
}
/// Remove analysis passes that are not used any longer
@@ -719,6 +764,7 @@ void PMDataManager::add(Pass *P,
Pass *PRequired = *I;
unsigned RDepth = 0;
+ assert (PRequired->getResolver() && "Analysis Resolver is not set");
PMDataManager &DM = PRequired->getResolver()->getPMDataManager();
RDepth = DM.getDepth();
@@ -813,6 +859,7 @@ void PMDataManager::initializeAnalysisImpl(Pass *P) {
// If that is not the case then it will raise an assert when it is used.
continue;
AnalysisResolver *AR = P->getResolver();
+ assert (AR && "Analysis Resolver is not set");
AR->addAnalysisImplsPair(*I, Impl);
}
}
@@ -1202,6 +1249,9 @@ bool FPPassManager::runOnFunction(Function &F) {
removeNotPreservedAnalysis(FP);
recordAvailableAnalysis(FP);
removeDeadPasses(FP, F.getNameStart(), ON_FUNCTION_MSG);
+
+ // Verify dominator information if it is available and preserved.
+ verifyDomInfo(*FP, F);
}
return Changed;
}