From abbaa506adabcbe8de9fa88c66138c81907333a8 Mon Sep 17 00:00:00 2001 From: David Mak Date: Mon, 9 Sep 2024 14:27:10 +0800 Subject: [PATCH] [standalone] Remove redundant recreation of TargetMachine --- nac3standalone/src/main.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index 7f2247b38..c307b93d3 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -279,18 +279,14 @@ fn main() { reloc_mode: RelocMode::PIC, ..host_target_machine }; + let target_machine = target_machine_options + .create_target_machine(opt_level) + .expect("couldn't create target machine"); let context = nac3core::inkwell::context::Context::create(); - let size_t = context - .ptr_sized_int_type( - &target_machine_options - .create_target_machine(opt_level) - .map(|tm| tm.get_target_data()) - .unwrap(), - None, - ) - .get_bit_width(); + let size_t = + context.ptr_sized_int_type(&target_machine.get_target_data(), None).get_bit_width(); let program = match fs::read_to_string(file_name.clone()) { Ok(program) => program, @@ -458,11 +454,6 @@ fn main() { } // Optimize `main` - let target_machine = llvm_options - .target - .create_target_machine(llvm_options.opt_level) - .expect("couldn't create target machine"); - let pass_options = PassBuilderOptions::create(); pass_options.set_merge_functions(true); let passes = format!("default", opt_level as u32);