Skip to content

Inefficient codegen in builder pattern with existed copyable base value #130592

Open
@CrazyboyQCD

Description

@CrazyboyQCD

First found in #128081 (comment)

In a builder pattern code, when building with existed copyable base value, codegen isn't efficient like partial copy.
This can be reproduced on both argument value and constant value.

Full copy and patial copy:
C version: https://godbolt.org/z/z3fWsKhqE
Rust version: https://godbolt.org/z/MeGf8E5Gd

Existed value and non existed value:
C version: https://godbolt.org/z/9z3x3Kv5c
Rust version: https://godbolt.org/z/vWEaEfd3e

Real use case examaple in rust: https://godbolt.org/z/3q9jn5c1o

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.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions