Auto merge of #100035 - workingjubilee:merge-functions, r=nikic

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.

Closes #98215.
This commit is contained in:
bors 2022-08-05 23:11:49 +00:00
commit 55f46419af
2 changed files with 9 additions and 4 deletions

View File

@ -256,8 +256,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 {