Conversation

What are the performance consequences in practice of disabling strict aliasing in C, anyway? Rust doesn't have it and it didn't actually tell LLVM about noalias until relatively recently, and I think enabling noalias only got ~ 5% avg so far (though that'll probably improve).
2
Rust can provide much better aliasing information than C based on the properties of & and &mut which is equivalent to putting restrict on nearly all pointers in C code. It hasn't been able to leverage that as much as it should be able to on top of LLVM due to optimization bugs.
2
5
&T for any type T without interior mutability (which is tracked by the type system) and any &mut U type can be marked with the same noalias markers used by Clang for restrict since noalias means no memory dependencies between them and is valid even if the address is the same.
2
4
Rust is actually doing that now, though, isn't it? I think it was enabled several months ago. Performance definitely improved, I just think ~5% isn't enough to justify something as intrusive as strict aliasing is for C (and it should be able to do *better* than strict aliasing).
1
1
Rust is currently only adding noalias markers to function parameters when the parameter is Box<T>, &mut T or &T with the &T case limited to when the type T has no interior mutability (i.e. it does not contain any UnsafeCell such as Cell, RefCell, Mutex, etc. use internally).
2
2
Rust isn't using scoped noalias metadata yet due to a mix of LLVM bugs and the need to clearly define the semantics for unsafe code. The LLVM scoped noalias metadata also has limitations in how it's designed. It can only mark the outermost pointer used in a function parameter.
2
2
Show replies