Unnamed repository; edit this file 'description' to name the repository.
Rollup merge of #158214 - hanna-kruppe:issue-158206, r=cjgillot
Don't try to remove assignments in SimplifyComparisonIntegral
The pass tried to opportunistically clean up an unnecessary assign statement if there's no other use of the comparison folded into a `switchInt`. The reasoning was that `switchInt(move _N)` prevents uses of `_N` in other blocks. The immediate problem is that the pass didn't check for other uses of the comparison result *in the same block*. This PR drops the cleanup logic entirely to fix rust-lang/rust#158206.
One could try to salvage the cleanup by doing another scan through the basic block and looking for other uses of the temporary. However, the other half of the reasoning (`move` prevents later uses) is also dubious. As the documentation of `Operand::Move` says:
> This may additionally overwrite the place with uninit bytes, depending on how we decide in [UCG#188](https://github.com/rust-lang/unsafe-code-guidelines/issues/188). You should not emit MIR that may attempt a subsequent second load of this place without first re-initializing it.
This does not justify assuming "moves makes place uninitialized" semantics for the purpose of optimizations. At least for now, it doesn't seem possible to do this cleanup soundly without a whole-function analysis that looks at all uses, i.e., a general dead code elimination pass.