Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liveness in stack closures #2447

Closed
nikomatsakis opened this issue May 25, 2012 · 1 comment
Closed

liveness in stack closures #2447

nikomatsakis opened this issue May 25, 2012 · 1 comment
Assignees
Labels
A-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@nikomatsakis
Copy link
Contributor

The liveness pass should be extended to treat stack closures just like a loop body. This is relatively straightforward. It would allow for a couple of nice things:

  • it'd be more efficient in some cases (I believe the last_use code I replaced actually did this right) because we could move values in if there were a loop like

    let mut v = [];
    uint::range(...) { |i|
    use(v);
    v = [some new vec];
    }

  • it allows us to right fold for arbitrary iteration with only moves:

    let mut b = b0;
    for as.each { |a|
    b <- op(a, b);
    }
    ret b;

    In this case, the value in op(e, b) is actually moved out temporarily but always restored by the end of the loop. This would work today with a while loop but not with a closure-based loop.

@ghost ghost assigned nikomatsakis May 25, 2012
@nikomatsakis
Copy link
Contributor Author

it is not clear that this would be sound---we'd have to be wary of recursive calls etc. just going to close this.

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
)

This fixes a regression introduced in rust-lang#2439 when write symtab json is enabled. We still need to take that into consideration and remove them if needed.

This change also simplifies the write symtab json regression to avoid the out of disk space issue we've been seeing since rust-lang#2439.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

1 participant