#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>
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"),
}
}
+/// 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;
InheritedAnalysis[Index]->erase(Info);
}
}
-
}
/// Remove analysis passes that are not used any longer
Pass *PRequired = *I;
unsigned RDepth = 0;
+ assert (PRequired->getResolver() && "Analysis Resolver is not set");
PMDataManager &DM = PRequired->getResolver()->getPMDataManager();
RDepth = DM.getDepth();
// 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);
}
}
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;
}