-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc_trans: do not generate allocas for unused locals. #35916
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 6b95606 has been approved by |
eddyb
added
the
beta-nominated
Nominated for backporting to the compiler in the beta channel.
label
Aug 23, 2016
eddyb
added a commit
to eddyb/rust
that referenced
this pull request
Aug 23, 2016
rustc_trans: do not generate allocas for unused locals. This fixes a regression observed in a [`mio` test](https://travis-ci.org/carllerche/mio/jobs/152142886) which was referencing a 4MB `const` array. Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind. As the array doesn't have an immediate type, an `alloca` was generated for it, even though it had no uses. The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used. And if it can't be used, it doesn't get an `alloca`, even if the type would otherwise demand it. This could change in the future, but all the MIR we generate now doesn't break that rule.
This was referenced Aug 23, 2016
eddyb
added a commit
to eddyb/rust
that referenced
this pull request
Aug 23, 2016
rustc_trans: do not generate allocas for unused locals. This fixes a regression observed in a [`mio` test](https://travis-ci.org/carllerche/mio/jobs/152142886) which was referencing a 4MB `const` array. Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind. As the array doesn't have an immediate type, an `alloca` was generated for it, even though it had no uses. The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used. And if it can't be used, it doesn't get an `alloca`, even if the type would otherwise demand it. This could change in the future, but all the MIR we generate now doesn't break that rule.
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Aug 25, 2016
rustc_trans: do not generate allocas for unused locals. This fixes a regression observed in a [`mio` test](https://travis-ci.org/carllerche/mio/jobs/152142886) which was referencing a 4MB `const` array. Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind. As the array doesn't have an immediate type, an `alloca` was generated for it, even though it had no uses. The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used. And if it can't be used, it doesn't get an `alloca`, even if the type would otherwise demand it. This could change in the future, but all the MIR we generate now doesn't break that rule.
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
Aug 25, 2016
rustc_trans: do not generate allocas for unused locals. This fixes a regression observed in a [`mio` test](https://travis-ci.org/carllerche/mio/jobs/152142886) which was referencing a 4MB `const` array. Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind. As the array doesn't have an immediate type, an `alloca` was generated for it, even though it had no uses. The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used. And if it can't be used, it doesn't get an `alloca`, even if the type would otherwise demand it. This could change in the future, but all the MIR we generate now doesn't break that rule.
nrc
added
the
beta-accepted
Accepted for backporting to the compiler in the beta channel.
label
Aug 25, 2016
Merged
brson
removed
the
beta-nominated
Nominated for backporting to the compiler in the beta channel.
label
Sep 16, 2016
bors
added a commit
that referenced
this pull request
Nov 3, 2016
A way to remove otherwise unused locals from MIR There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts. PR like #35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort. @nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation. r? @eddyb or @nikomatsakis
bors
added a commit
that referenced
this pull request
Nov 3, 2016
A way to remove otherwise unused locals from MIR There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts. PR like #35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort. @nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation. r? @eddyb or @nikomatsakis
bors
added a commit
that referenced
this pull request
Nov 4, 2016
A way to remove otherwise unused locals from MIR There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts. PR like #35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort. @nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation. r? @eddyb or @nikomatsakis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a regression observed in a
mio
test which was referencing a 4MBconst
array.Even though MIR rvalue promotion would promote the borrow of the array, a dead temp was left behind.
As the array doesn't have an immediate type, an
alloca
was generated for it, even though it had no uses.The fix is pretty dumb: assume that locals need to be borrowed or assigned before being used.
And if it can't be used, it doesn't get an
alloca
, even if the type would otherwise demand it.This could change in the future, but all the MIR we generate now doesn't break that rule.