Conversation

&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
TBAA in C is incredibly weak especially since char * can alias with everything and a lot of the types are simply defined as typedefs of other types in practice or maybe even as required by the standard. It's incredibly hit or miss and lots of stuff gets in the way of it working.
1
4
It should just be removed. People should use restrict if they want it, and while the definition of restrict in the standard is screwed up it's defined in a reasonable way by Clang at least even though there were massive implementation bugs which are now largely fixed due to Rust.
1
4
TBAA is compiler people doing an optimization that was never intended to be supported and was clearly a standards violation and was then gradually brought into the standard in order to permit what compilers were already doing. It shouldn't have ever been a thing. Super broken.
1
3
It's completely reasonable to want to do those optimizations but real world C code is in violation of the rules and it was not historically permitted or intended in the initial standards. They decided to bend and outright break the rules and then "fixed" standards to allow it.
1
4
Also, hurting the performance of C code is a good thing. I'm all for disabling optimizations that were never actually standards compliant for C. LLVM is also wrongly applying the modern C++ rules for fudging the halting problem to C and legacy C++ when it's not actually allowed.
1
4
It really shouldn't be a thing that compilers add incorrect optimizations to make C faster when what they're doing is unsafe in practice and non-standards-compliant. Personally, I think the ever increasing cost of all the weak mitigations gradually adding up will help replace C.
1
6
Show replies