
Why does Rust not optimize code assuming that mutable references cannot alias? - nickm12
https://stackoverflow.com/questions/57259126/why-does-the-rust-compiler-not-optimize-code-assuming-that-two-mutable-reference
======
DannyBee
These are not even the only fun bugs and issues that lurk in how various
alias/invariant/etc related things are designed in llvm, and trying to figure
out the regions they cover.

For anyone ever designing a compiler, do yourself a huge favor: do not try to
scope aliasing/etc info using metadata. Make it an explicit part of the ir
somehow so that the control and dataflow is explicit to the compiler. (GCC
went thru the same fun before LLVM did).

It seems like a good idea at first, but it is almost impossible to keep it
conservatively correct during transforms (unless you drop it when anything at
all changes, which also turns out badly)

