1
Fork 0

refactor write_output_file to merge two invocation paths into one.

This commit is contained in:
Felix S. Klock II 2022-01-26 10:26:43 -05:00
parent 09d52bc5d4
commit 927de94316

View file

@ -56,28 +56,24 @@ pub fn write_output_file<'ll>(
file_type: llvm::FileType, file_type: llvm::FileType,
self_profiler_ref: &SelfProfilerRef, self_profiler_ref: &SelfProfilerRef,
) -> Result<(), FatalError> { ) -> Result<(), FatalError> {
debug!("write_output_file output={:?} dwo_output={:?}", output, dwo_output);
unsafe { unsafe {
let output_c = path_to_c_string(output); let output_c = path_to_c_string(output);
let result = if let Some(dwo_output) = dwo_output { let dwo_output_c;
let dwo_output_c = path_to_c_string(dwo_output); let dwo_output_ptr = if let Some(dwo_output) = dwo_output {
llvm::LLVMRustWriteOutputFile( dwo_output_c = path_to_c_string(dwo_output);
target, dwo_output_c.as_ptr()
pm,
m,
output_c.as_ptr(),
dwo_output_c.as_ptr(),
file_type,
)
} else { } else {
llvm::LLVMRustWriteOutputFile( std::ptr::null()
};
let result = llvm::LLVMRustWriteOutputFile(
target, target,
pm, pm,
m, m,
output_c.as_ptr(), output_c.as_ptr(),
std::ptr::null(), dwo_output_ptr,
file_type, file_type,
) );
};
// Record artifact sizes for self-profiling // Record artifact sizes for self-profiling
if result == llvm::LLVMRustResult::Success { if result == llvm::LLVMRustResult::Success {