Conversation

LLVM has to translate them to the new scope when it does inlining, including converting noalias markers on function parameters to scoped metadata. This was yet another bug in how that kind of thing gets handled. It's complex and has to handle all the details / interactions right.
1
4
Rust has uncovered a bunch of these LLVM bugs. It has consistently been caused by issues in LLVM rather than in rustc. It also definitely impacts C but restrict isn't widely used. Most references in Rust should be marked noalias. It means no memory dependencies between them.
1
6
LLVM NoAlias means that two pointers do not have memory dependencies between them, i.e. there aren't writes made through one of the pointers that are visible through the other. Rust guarantees that while an &mut reference is active/usable, nothing else reads/writes that data.
1
2
It could also be marking most &T references as NoAlias too because it means immutable in the absence of interior mutability which is something that the type system understands. Means Rust could mark vast majority of references as NoAlias and get much more aggressive optimization.
1
1
There have been LLVM bugs in how it implements alias analysis, propagation of noalias metadata across functions (inlining in paricular), optimizations wrongly concluding NoAlias response for 2 pointers means they can do something, and just optimizations wrong for other reasons.
1
1
Since heavily using this enables a lot more optimization in general you are going to find edge case bugs that never came up before because those optimizations got triggered far less optimizations and didn't actually get exercised nearly as much. It's a stress test and it fails.
1
3
Imagine a large C program where 95% of pointers were marked restrict. The markings on all those pointers were all done correctly. Clang and GCC simply don't deal with that kind of code in the real world and the fact that they're thoroughly broken just doesn't come up with C.
1
5
It could output noalias metadata in some other cases too. You know what's really sad? This was first attempted something like 6-7 years ago. I was involved in the initial work on it, back when I was working on Rust. LLVM was broken then, and 100 or so fixes later is still broken.
1
5
Rust compiler divides up code into codegen units itself for incremental builds / parallelism. If you use 1 codegen unit, then that's essentially fat LTO within the crate. Default is multiple codegen units with ThinLTO to combine them together but not across crates unless you ask.
1
2
Show replies