Skip to content

MIR trans cannot handle casting for call return values. #33873

Closed
@eddyb

Description

@eddyb

In the following example, bar optimizes to ret i8 undef because the return value is cast into an i32 in foo and has to be converted back at the call site. The old trans code does this with a gnarly memcpy which should handle all of the possible situations, if the comment on it is of any indication.
I believe my use of ArgType::store for storing the return value in its destination was unwarranted.
Since then, @Aatch has refactored that logic into its own function, which should do the memcpy.
cc @nagisa @dotdash

#![crate_type = "lib"]
#![feature(rustc_attrs)]

pub extern "C" fn foo() -> (u8, u8, u8) {
    (1, 2, 3)
}

#[rustc_mir]
pub fn bar() -> u8 {
    foo().2
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions