diff --git a/llvm/lib/Transforms/Yk/ControlPoint.cpp b/llvm/lib/Transforms/Yk/ControlPoint.cpp index 2ba708baf20492..5a365020bf6130 100644 --- a/llvm/lib/Transforms/Yk/ControlPoint.cpp +++ b/llvm/lib/Transforms/Yk/ControlPoint.cpp @@ -376,7 +376,14 @@ class YkControlPoint : public ModulePass { Builder.SetInsertPoint(BB); Builder.CreateCondBr(NewCtrlPointCallInst, ExitBB, ContBB); - // Generate new control point logic. +#ifndef NDEBUG + // Our pass runs after LLVM normally does its verify pass. In debug builds + // we run it again to check that our pass is generating valid IR. + if (verifyModule(M, &errs())) { + Context.emitError("Control point pass generated invalid IR!"); + return false; + } +#endif return true; } };