Auto merge of #66952 - 0dvictor:print, r=rkruppe

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:
bors 2019-12-05 11:23:26 +00:00
commit 1e2a73867d
3 changed files with 9 additions and 50 deletions

View file

@ -588,14 +588,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)
})?;
}