Skip to content

Commit

Permalink
Fix enabling optimizations for LLVM 16
Browse files Browse the repository at this point in the history
The changes to how passes are run in the new pass manager means simply
setting the optimization level isn't enough, instead you have to add the
pass group "default<N>" where "N" is "O1", "O2" or "O3". This ensures
that for example the module inliner is correctly enabled when using
--opt=aggressive.

The resulting performance still isn't great as LLVM doesn't
inline/optimize across modules, but it's better than --opt=aggressive
effectively doing very little.
  • Loading branch information
yorickpeterse committed Apr 4, 2024
1 parent 1d4bad2 commit 4f87499
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/llvm/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ impl<'a> Worker<'a> {
fn run_passes(&self, module: &Module) {
let layout = self.machine.get_target_data().get_data_layout();
let opts = PassBuilderOptions::create();
let passes = &["mem2reg"];
let passes = if let Opt::Aggressive = self.shared.state.config.opt {
&["default<O3>"]
} else {
&["mem2reg"]
};

module.set_data_layout(&layout);
module.set_triple(&self.machine.get_triple());
Expand Down

0 comments on commit 4f87499

Please sign in to comment.