Skip to content

Commit

Permalink
Rollup merge of rust-lang#93331 - pnkfelix:refactor-write-output-file…
Browse files Browse the repository at this point in the history
…, r=oli-obk

refactor write_output_file to merge two invocation paths into one.

this is a trivial refactor I did while I was investigating issue rust-lang#91671.
  • Loading branch information
matthiaskrgr committed Jun 10, 2022
2 parents ec55c61 + 927de94 commit 0777113
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Expand Up @@ -56,28 +56,24 @@ pub fn write_output_file<'ll>(
file_type: llvm::FileType,
self_profiler_ref: &SelfProfilerRef,
) -> Result<(), FatalError> {
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
unsafe {
let output_c = path_to_c_string(output);
let result = if let Some(dwo_output) = dwo_output {
let dwo_output_c = path_to_c_string(dwo_output);
llvm::LLVMRustWriteOutputFile(
target,
pm,
m,
output_c.as_ptr(),
dwo_output_c.as_ptr(),
file_type,
)
let dwo_output_c;
let dwo_output_ptr = if let Some(dwo_output) = dwo_output {
dwo_output_c = path_to_c_string(dwo_output);
dwo_output_c.as_ptr()
} else {
llvm::LLVMRustWriteOutputFile(
target,
pm,
m,
output_c.as_ptr(),
std::ptr::null(),
file_type,
)
std::ptr::null()
};
let result = llvm::LLVMRustWriteOutputFile(
target,
pm,
m,
output_c.as_ptr(),
dwo_output_ptr,
file_type,
);

// Record artifact sizes for self-profiling
if result == llvm::LLVMRustResult::Success {
Expand Down

0 comments on commit 0777113

Please sign in to comment.