Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#35916 - eddyb:mir-no-dead-allocas, r=Aatch
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.
- Loading branch information