Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 Wasn't there a twitter thread just yesterday about this pattern?

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