Index: lib/IR/LegacyPassManager.cpp =================================================================== --- lib/IR/LegacyPassManager.cpp +++ lib/IR/LegacyPassManager.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/LegacyPassManagers.h" #include "llvm/IR/LegacyPassNameParser.h" #include "llvm/IR/Module.h" +#include "llvm/IR/Verifier.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -84,6 +85,12 @@ llvm::cl::desc("Print IR after each pass"), cl::init(false)); +static cl::opt VerifyAfterAll( + "verify-after-all", + llvm::cl::desc( + "Verify the IR after each pass (and crash if the IR does not verify)"), + cl::init(false)); + static cl::list PrintFuncsList("filter-print-funcs", cl::value_desc("function names"), cl::desc("Only print IR for functions whose name " @@ -696,6 +703,11 @@ dbgs(), std::string("*** IR Dump After ") + P->getPassName() + " ***"); PP->assignPassManager(activeStack, getTopLevelPassManagerType()); } + + if (PI && !PI->isAnalysis() && VerifyAfterAll) { + createVerifierPass()->assignPassManager(activeStack, + getTopLevelPassManagerType()); + } } /// Find the pass that implements Analysis AID. Search immutable