Conversation

Mutually recursive function calls are another case that's very difficult. In order to avoid treating every single function call as needing to have that universal side effect inserted (destroying tons of optimization), the compiler would have to analyze the call graph.
1
Even if the recursion isn't via guaranteed tail calls stack overflow is well-defined and safe in these languages. It CANNOT be replaced with arbitrary memory corruption. They're saying that even remotely safe languages should have significantly worse compile-time and performance.
2
It's difficult for a compiler to know if it happens though. It would need to do whole program analysis to build a potential call graph to avoid being able to insert a massive number of these performance killing intrinsics. Indirect calls also make it much harder to figure it out.
1
It penalizes code without any recursion, because the compiler doesn't know that. You really just end up needing to do the same analysis LLVM should be doing yourself in the higher level compiler: an internal function attribute for always_returns and functions without it get this.
2
It's far from one of the most important of these issues, but I feel like it's an incredibly useful case study of how broken the development process and decision making for LLVM is. It's a nice simple, easily demonstrated example of what happens in much more complex cases.
1
Basically, they are often right when they brush aside complaints about optimizations by saying something is undefined. That's fine. However, they also use that excuse to brush aside complaints / justify things that are legitimately wrong and it actually ends up staying that way.
1
Show replies