When --debug is specified, only print the entire module bitcode twice.

Fixes issue #77.  Previously, it dumped out the entire module every time
a new function was defined, which got to be quite a lot of output by
the time the stdlib functions were all added!
This commit is contained in:
Matt Pharr
2011-07-29 07:26:37 +02:00
parent 158bd6ef9e
commit 25676d5643

View File

@@ -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");
}
}
}
}
}