Use Module::print() instead of a PrintModulePass

llvm::Module has a print() method. It is unnecessary to create a
pass just for the purpose of printing LLVM IR.
This commit is contained in:
Victor Ding 2019-12-02 20:53:01 +11:00
parent f5c81e0a98
commit 85df207ecc
3 changed files with 9 additions and 50 deletions

View file

@ -587,14 +587,11 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<LlvmCodegenBackend>,
cursor.position() as size_t
}
with_codegen(tm, llmod, config.no_builtins, |cpm| {
let result =
llvm::LLVMRustPrintModule(cpm, llmod, out_c.as_ptr(), demangle_callback);
llvm::LLVMDisposePassManager(cpm);
result.into_result().map_err(|()| {
let msg = format!("failed to write LLVM IR to {}", out.display());
llvm_err(diag_handler, &msg)
})
let result =
llvm::LLVMRustPrintModule(llmod, out_c.as_ptr(), demangle_callback);
result.into_result().map_err(|()| {
let msg = format!("failed to write LLVM IR to {}", out.display());
llvm_err(diag_handler, &msg)
})?;
}