Convert a chained if-else to a match.

It makes things a little clearer.
This commit is contained in:
Nicholas Nethercote 2020-03-26 13:53:03 +11:00
parent 87ef16c9dc
commit a50cca920d

View file

@ -751,11 +751,13 @@ pub(crate) unsafe fn codegen(
})?; })?;
} }
if config_emit_object_code { match config.emit_obj {
EmitObj::ObjectCode(_) => {
if !config.no_integrated_as { if !config.no_integrated_as {
let _timer = cgcx let _timer = cgcx.prof.generic_activity_with_arg(
.prof "LLVM_module_codegen_emit_obj",
.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &module.name[..]); &module.name[..],
);
with_codegen(tm, llmod, config.no_builtins, |cpm| { with_codegen(tm, llmod, config.no_builtins, |cpm| {
write_output_file( write_output_file(
diag_handler, diag_handler,
@ -767,17 +769,21 @@ pub(crate) unsafe fn codegen(
) )
})?; })?;
} else { } else {
let _timer = cgcx let _timer = cgcx.prof.generic_activity_with_arg(
.prof "LLVM_module_codegen_asm_to_obj",
.generic_activity_with_arg("LLVM_module_codegen_asm_to_obj", &module.name[..]); &module.name[..],
let assembly = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name); );
let assembly =
cgcx.output_filenames.temp_path(OutputType::Assembly, module_name);
run_assembler(cgcx, diag_handler, &assembly, &obj_out); run_assembler(cgcx, diag_handler, &assembly, &obj_out);
if !config.emit_asm && !cgcx.save_temps { if !config.emit_asm && !cgcx.save_temps {
drop(fs::remove_file(&assembly)); drop(fs::remove_file(&assembly));
} }
} }
} else if config.emit_obj == EmitObj::Bitcode { }
EmitObj::Bitcode => {
debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out); debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
if let Err(e) = link_or_copy(&bc_out, &obj_out) { if let Err(e) = link_or_copy(&bc_out, &obj_out) {
diag_handler.err(&format!("failed to copy bitcode to object file: {}", e)); diag_handler.err(&format!("failed to copy bitcode to object file: {}", e));
@ -791,6 +797,9 @@ pub(crate) unsafe fn codegen(
} }
} }
EmitObj::None => {}
}
drop(handlers); drop(handlers);
} }
Ok(module.into_compiled_module( Ok(module.into_compiled_module(