Enable function merging when opt is for size

It is, of course, natural to want to merge aliasing functions when
optimizing for code size, since that can eliminate several bytes.
And an exhaustive match helps make the code less brittle.
This commit is contained in:
Jubilee Young 2022-08-01 14:04:14 -07:00
parent b4151a41a0
commit 80c9012e42
2 changed files with 9 additions and 4 deletions

View File

@ -255,8 +255,11 @@ macro_rules! if_regular {
{
MergeFunctions::Disabled => false,
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
sess.opts.optimize == config::OptLevel::Default
|| sess.opts.optimize == config::OptLevel::Aggressive
use config::OptLevel::*;
match sess.opts.optimize {
Aggressive | Default | SizeMin | Size => true,
Less | No => false,
}
}
},

View File

@ -1,7 +1,9 @@
// compile-flags: -O
// revisions: O Os
//[Os] compile-flags: -Copt-level=s
//[O] compile-flags: -O
#![crate_type = "lib"]
// CHECK: @func2 = {{.*}}alias{{.*}}@func1
// CHECK: @func{{2|1}} = {{.*}}alias{{.*}}@func{{1|2}}
#[no_mangle]
pub fn func1(c: char) -> bool {