diff --git a/module.cpp b/module.cpp index 2250d032..74e3fef2 100644 --- a/module.cpp +++ b/module.cpp @@ -798,14 +798,15 @@ Module::AddFunction(DeclSpecs *ds, Declarator *decl, Stmt *code) { } if (errorCount == 0) { - if (g->debugPrint) { - llvm::PassManager ppm; - ppm.add(llvm::createPrintModulePass(&llvm::outs())); - ppm.run(*module); + if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { + if (g->debugPrint) { + llvm::PassManager ppm; + ppm.add(llvm::createPrintModulePass(&llvm::outs())); + ppm.run(*module); + } + FATAL("Function verificication failed"); } - llvm::verifyFunction(*function); - // If the function is 'export'-qualified, emit a second version of // it without a mask parameter and without name mangling so that // the application can call it @@ -828,8 +829,17 @@ Module::AddFunction(DeclSpecs *ds, Declarator *decl, Stmt *code) { FunctionEmitContext ec(functionType->GetReturnType(), appFunction, funSym, firstStmtPos); lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code); - if (errorCount == 0) - llvm::verifyFunction(*appFunction); + if (errorCount == 0) { + if (llvm::verifyFunction(*appFunction, + llvm::ReturnStatusAction) == true) { + if (g->debugPrint) { + llvm::PassManager ppm; + ppm.add(llvm::createPrintModulePass(&llvm::outs())); + ppm.run(*module); + } + FATAL("Function verificication failed"); + } + } } } }