]> git.lizzy.rs Git - rust.git/commit
Auto merge of #36306 - nagisa:mir-local-cleanup, r=eddyb
authorbors <bors@rust-lang.org>
Fri, 4 Nov 2016 05:58:55 +0000 (22:58 -0700)
committerGitHub <noreply@github.com>
Fri, 4 Nov 2016 05:58:55 +0000 (22:58 -0700)
commit49c36bf16f80a9d9d4e96172b1bc8cb7279de468
treed45fc028bc95be0f72a19744ed6c535e20ec5216
parentac919fcd9d4a958baf99b2f2ed5c3d38a2ebf9d0
parent475236770fe4fd973957d734a074a54c5ac88c87
Auto merge of #36306 - nagisa:mir-local-cleanup, r=eddyb

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 https://github.com/rust-lang/rust/pull/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
src/librustc_driver/driver.rs