Mark &mut parameters as noalias#6742
Conversation
This marks `&mut` function arguments with the `noalias` attribute. Since the borrow checker enforces this property, this is worth doing. I'm not sure if the place I'm doing it in is ideal, but it generates the correct code. Closes #6350
|
Do we actually know that all &mut parameters are no-alias? This seems pretty unlikely to me. |
|
@brson: yes, LLVM's understanding of You're allowed to have other references to the memory before and after the function, and the function can create more references to the value from the pointer it's passed. Technically, |
|
@thestinger If all Rust code was safe and obeyed borrow semantics then this would be true, but there is plenty of unsafe code that mutates immutable pointers. Do all those unsafe blocks preserve the assumption that |
|
@brson: I don't think we'll be able to do this for immutable pointers for a long time - but I doubt there's anything breaking the rules for To break the rules, the function would need to have two borrowed pointer parameters with one or both being |
This marks
&mutfunction arguments with thenoaliasattribute. Since the borrow checker enforces this property, this is worth doing.I'm not sure if the place I'm doing it in is ideal, but it generates the correct code.
Closes #6350