+/// verifyDomInfo - Verify dominator information if it is available.
+void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
+ if (!VerifyDomInfo || !P.getResolver())
+ return;
+
+ 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");
+ }
+}
+
+/// Remove Analysis not preserved by Pass P