mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Improve OptSize
implementation in Roc
1. Use the llvm `Oz` pipeline. 2. Avoid adding extra optimization passes. This shrunk rocci-bird by ~16%.
This commit is contained in:
parent
a323dd8e92
commit
dc539f759d
1 changed files with 8 additions and 3 deletions
|
@ -1124,7 +1124,11 @@ pub fn construct_optimization_passes<'a>(
|
||||||
}
|
}
|
||||||
OptLevel::Size => {
|
OptLevel::Size => {
|
||||||
pmb.set_optimization_level(OptimizationLevel::Default);
|
pmb.set_optimization_level(OptimizationLevel::Default);
|
||||||
|
// 2 is equivalent to `-Oz`.
|
||||||
|
pmb.set_size_level(2);
|
||||||
|
|
||||||
// TODO: For some usecase, like embedded, it is useful to expose this and tune it.
|
// TODO: For some usecase, like embedded, it is useful to expose this and tune it.
|
||||||
|
// This really depends on if inlining causes enough simplifications to reduce code size.
|
||||||
pmb.set_inliner_with_threshold(50);
|
pmb.set_inliner_with_threshold(50);
|
||||||
}
|
}
|
||||||
OptLevel::Optimize => {
|
OptLevel::Optimize => {
|
||||||
|
@ -1134,9 +1138,10 @@ pub fn construct_optimization_passes<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add optimization passes for Size and Optimize.
|
// Add extra optimization passes for Optimize.
|
||||||
if matches!(opt_level, OptLevel::Size | OptLevel::Optimize) {
|
if matches!(opt_level, OptLevel::Optimize) {
|
||||||
// TODO figure out which of these actually help
|
// TODO: figure out which of these actually help.
|
||||||
|
// Note, llvm probably already runs all of these as part of Aggressive.
|
||||||
|
|
||||||
// function passes
|
// function passes
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue