From 2a38d5160e2063cf9c78f6fe577a97079c710d98 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 21 Sep 2023 15:34:05 +0800 Subject: [PATCH] meta: Respect opt flags when performing whole-module optimization --- nac3artiq/src/lib.rs | 3 ++- nac3core/src/codegen/mod.rs | 1 - nac3standalone/src/main.rs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 18eeb5dc7..68e837bdc 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -660,7 +660,8 @@ impl Nac3 { let pass_options = PassBuilderOptions::create(); pass_options.set_merge_functions(true); - let result = main.run_passes("default", &target_machine, pass_options); + let passes = format!("default", self.llvm_options.opt_level as u32); + let result = main.run_passes(passes.as_str(), &target_machine, pass_options); if let Err(err) = result { panic!("Failed to run optimization for module `main`: {}", err.to_string()); } diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index 67176c856..8d2e39f22 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -328,7 +328,6 @@ impl WorkerRegistry { self.llvm_options.opt_level ).expect(format!("could not create target machine from properties {:?}", self.llvm_options.target).as_str()); let passes = format!("default", self.llvm_options.opt_level as u32); - let result = module.run_passes(passes.as_str(), &target_machine, pass_options); if let Err(err) = result { panic!("Failed to run optimization for module `{}`: {}", diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index d45b8759a..16f3aaef5 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -370,7 +370,8 @@ fn main() { let pass_options = PassBuilderOptions::create(); pass_options.set_merge_functions(true); - let result = main.run_passes("default", &target_machine, pass_options); + let passes = format!("default", opt_level as u32); + let result = main.run_passes(passes.as_str(), &target_machine, pass_options); if let Err(err) = result { panic!("Failed to run optimization for module `main`: {}", err.to_string()); }