Skip to content

Increased code size due to unnecessary memcpy libcall in MaybeUninit::assume_init #96487

@piegamesde

Description

@piegamesde

After updating the compiler toolchain, I noticed that my binary got about 100 bytes larger. In my extremely size constrained environment, this is an increase of 5%. After a lot of minimizing, I tracked the main increase down to MaybeUninit::assume_init. It adds a new call to libc's memcpy. As far as I can tell, the code is moving the value on the stack a few bytes around, which is pointless (alignment should not be the issue here).

This might be related to #61011

Code

Godbolt link

Version it worked on

The last version I got it to run on was nightly-2022-02-01, but it might be working until as late as 2022-02-28 (I had some unrelated compile errors that made bisecting hard).

Version with regression

The older nightly with regression is 2022-03-12

rustc --version --verbose:

rustc 1.61.0-nightly (335ffbfa5 2022-03-11)
binary: rustc
commit-hash: 335ffbfa547df94ac236f5c56130cecf99c8d82b
commit-date: 2022-03-11
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

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.I-heavyIssue: Problems and improvements with respect to binary size of generated code.I-slowIssue: Problems and improvements with respect to performance of generated code.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions