Skip to content

Codegen depends on let-variable ordering for unclear reasons #131987

Open
@CrazyboyQCD

Description

@CrazyboyQCD

https://godbolt.org/z/Wx1rvE6vq

use std::borrow::Cow;

pub struct Error {
    message: Cow<'static, str>,
    cause: Option<Box<[u8]>>,
}
#[no_mangle]
pub fn declear_before(v: u64) -> Error {
    let s = format!("{v}");
    let mut e = Error {
        message: Cow::Borrowed(""),
        cause: None,
    };
    e.message = s.into();
    e
}

Declear s before Error produces better codegen than declear after.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationA-panicArea: Panicking machineryC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-heavyIssue: Problems and improvements with respect to binary size of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions