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 (errorCount == 0) {
if (g->debugPrint) { if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) {
llvm::PassManager ppm; if (g->debugPrint) {
ppm.add(llvm::createPrintModulePass(&llvm::outs())); llvm::PassManager ppm;
ppm.run(*module); 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 // If the function is 'export'-qualified, emit a second version of
// it without a mask parameter and without name mangling so that // it without a mask parameter and without name mangling so that
// the application can call it // the application can call it
@@ -828,8 +829,17 @@ Module::AddFunction(DeclSpecs *ds, Declarator *decl, Stmt *code) {
FunctionEmitContext ec(functionType->GetReturnType(), appFunction, funSym, FunctionEmitContext ec(functionType->GetReturnType(), appFunction, funSym,
firstStmtPos); firstStmtPos);
lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code); lEmitFunctionCode(&ec, appFunction, functionType, funSym, decl, code);
if (errorCount == 0) if (errorCount == 0) {
llvm::verifyFunction(*appFunction); 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");
}
}
} }
} }
} }