Skip to content

implement named return value optimization in the frontend #788

Closed
@steveklabnik

Description

@steveklabnik

Issue by mahkoh
Monday Oct 27, 2014 at 13:24 GMT

For earlier discussion, see rust-lang/rust#18363

This issue was labelled with: I-enhancement, I-slow in the Rust repository


extern crate test;

pub struct X {
    x: [u8, ..1 << 10],
}

pub fn f() -> X {
    let mut x: X = unsafe { std::mem::uninitialized() };
    for i in range(0, x.x.len()) {
        x.x[i] = i as u8;
    }
    x
}

fn main() {
    let x = f();
    test::black_box(&x);
}

This function needs 2k stack space even though f is being inlined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions