]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #35916 - eddyb:mir-no-dead-allocas, r=Aatch
authorManish Goregaokar <manishsmail@gmail.com>
Thu, 25 Aug 2016 08:22:52 +0000 (13:52 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Thu, 25 Aug 2016 11:38:00 +0000 (17:08 +0530)
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.


Trivial merge