diff options
| author | bors <bors@rust-lang.org> | 2024-11-08 08:00:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-08 08:00:08 +0000 |
| commit | 6295686a37ed731f1059b07157170c9ac56bf8c3 (patch) | |
| tree | 51a878e8edd0526792eb33cd5f46c0441b00f0d3 /compiler/rustc_codegen_llvm/src/lib.rs | |
| parent | 78bb5ee79e0261e8e47476b631da02acc1cb03ef (diff) | |
| parent | 4b904ceb464040ebf85e569b33cca11df563f1cd (diff) | |
| download | rust-6295686a37ed731f1059b07157170c9ac56bf8c3.tar.gz rust-6295686a37ed731f1059b07157170c9ac56bf8c3.zip | |
Auto merge of #132762 - Zalathar:rollup-qfgz165, r=Zalathar
Rollup of 5 pull requests Successful merges: - #132161 ([StableMIR] A few fixes to pretty printing) - #132389 (coverage: Simplify parts of coverage graph creation) - #132452 (coverage: Extract safe FFI wrapper functions to `llvm_cov`) - #132590 (Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats`) - #132738 (Initialize channel `Block`s directly on the heap) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/lib.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/lib.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index b85d28a2f1f..49e616b5371 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -22,7 +22,6 @@ use std::any::Any; use std::ffi::CStr; -use std::io::Write; use std::mem::ManuallyDrop; use back::owned_target_machine::OwnedTargetMachine; @@ -165,30 +164,12 @@ impl WriteBackendMethods for LlvmCodegenBackend { type ThinData = back::lto::ThinData; type ThinBuffer = back::lto::ThinBuffer; fn print_pass_timings(&self) { - unsafe { - let mut size = 0; - let cstr = llvm::LLVMRustPrintPassTimings(&raw mut size); - if cstr.is_null() { - println!("failed to get pass timings"); - } else { - let timings = std::slice::from_raw_parts(cstr as *const u8, size); - std::io::stdout().write_all(timings).unwrap(); - libc::free(cstr as *mut _); - } - } + let timings = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintPassTimings(s) }).unwrap(); + print!("{timings}"); } fn print_statistics(&self) { - unsafe { - let mut size = 0; - let cstr = llvm::LLVMRustPrintStatistics(&raw mut size); - if cstr.is_null() { - println!("failed to get pass stats"); - } else { - let stats = std::slice::from_raw_parts(cstr as *const u8, size); - std::io::stdout().write_all(stats).unwrap(); - libc::free(cstr as *mut _); - } - } + let stats = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintStatistics(s) }).unwrap(); + print!("{stats}"); } fn run_link( cgcx: &CodegenContext<Self>, |
