Skip to content

"-Z merge-functions" does not enable the MergeFunctions pass under opt-level=s #98215

Closed
@jrose-signal

Description

@jrose-signal

I tried compiling my crate with RUSTFLAGS="-Z merge-functions=aliases", but saw no difference in output size, whereas RUSTFLAGS="-C passes=mergefunc" showed a 1% improvement (not much but I'd take it). I think this is because of this code:

merge_functions: match sess
.opts
.debugging_opts
.merge_functions
.unwrap_or(sess.target.merge_functions)
{
MergeFunctions::Disabled => false,
MergeFunctions::Trampolines | MergeFunctions::Aliases => {
sess.opts.optimize == config::OptLevel::Default
|| sess.opts.optimize == config::OptLevel::Aggressive
}
},

which is probably intended to exclude opt-level=0 builds but should really at least allow Size (s) and SizeMin (z), if not enable them by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions