Skip to content

Commit 927de94

Browse files
committed
refactor write_output_file to merge two invocation paths into one.
1 parent 09d52bc commit 927de94

File tree

1 file changed

+14
-18
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+14
-18
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,24 @@ pub fn write_output_file<'ll>(
5656
file_type: llvm::FileType,
5757
self_profiler_ref: &SelfProfilerRef,
5858
) -> Result<(), FatalError> {
59+
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
5960
unsafe {
6061
let output_c = path_to_c_string(output);
61-
let result = if let Some(dwo_output) = dwo_output {
62-
let dwo_output_c = path_to_c_string(dwo_output);
63-
llvm::LLVMRustWriteOutputFile(
64-
target,
65-
pm,
66-
m,
67-
output_c.as_ptr(),
68-
dwo_output_c.as_ptr(),
69-
file_type,
70-
)
62+
let dwo_output_c;
63+
let dwo_output_ptr = if let Some(dwo_output) = dwo_output {
64+
dwo_output_c = path_to_c_string(dwo_output);
65+
dwo_output_c.as_ptr()
7166
} else {
72-
llvm::LLVMRustWriteOutputFile(
73-
target,
74-
pm,
75-
m,
76-
output_c.as_ptr(),
77-
std::ptr::null(),
78-
file_type,
79-
)
67+
std::ptr::null()
8068
};
69+
let result = llvm::LLVMRustWriteOutputFile(
70+
target,
71+
pm,
72+
m,
73+
output_c.as_ptr(),
74+
dwo_output_ptr,
75+
file_type,
76+
);
8177

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

0 commit comments

Comments
 (0)