Skip to content

same functions are not merged in library #91490

Description

@hellow554

I tried this code:

pub fn a(c: char) -> bool {
    c == 's' || c == 'm' || c == 'h' || c == 'd' || c == 'w'
}

pub fn b(c: char) -> bool {
    matches!(c, 's' | 'm' | 'h' | 'd' | 'w')
}

When compiled with the latest stable version and look at the objdump, I see a combined version of a and b, because they are optimized to the same instructions and then merged in the library.
On nightly (already bisected) two copies are stored and it takes the double amount of space (3.9kIB vs 4.1kIB).

Here's a godbolt link: https://rust.godbolt.org/z/zWovojdEE

Version it worked on

It most recently worked on: 1.57.0
Doesn't work since: 63cc2bb cc #88243 @nikic

@rustbot modify labels: +regression-from-stable-to-nightly +I-heavy

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-heavyIssue: Problems and improvements with respect to binary size of generated code.P-mediumMedium priorityregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions