3 ms·
Yeah, this is true. We do the equivalent of telling the compiler that things don't alias at function boundaries (i.e. restrict) and not much more. Nobody writ
by Manishearth 8y ago
Yeah, this is true.
We do the equivalent of telling the compiler that things don't alias at function boundaries (i.e. restrict) and not much more.
Nobody writes C code with restrict all over the place, which means that not only is this the finest grained level we can give this info to LLVM, it doesn't even necessarily support it well! We had to turn it off for &mut for a long time because of a bunch of bugs.
The weird thing is, to be able to do most optimizations LLVM does its own alias analysis anyway! (I don't know the details).
A lot of program analysis research is focused on improving alias analyses which are usually slow, imperfect, and global. Rust's aliasing info is "free" (you don't need to compute anything extra to get it), local, and perfect (ish). We really could get a lot of wins from doing our own aliasing-aware analyses, or by reordering the code in such a way so as to make it easier for LLVM (e.g., hoisting reads and writes to function boundaries so llvm just sees a bunch of locals)