Conversation

Replying to and
Clang similarly doesn't make much use of LLVM aggregates. In general, this is a sign that there's something wrong with the LLVM feature and it isn't a good idea to use it elsewhere if you expect correct and efficient code generation. C ABI support in LLVM is a total hack too.
1
4
Replying to and
Clang manually deals with implementing the C calling convention for structs instead of LLVM's C calling convention implementing it for aggregates. These workarounds in Clang cause many missed optimizations in LLVM, and LLVM also isn't optimized to deal well with first-class code.
1
5
Replying to and
Since Clang uses i8 for bool, optimization passes often haven't been implemented to handle i1. So, you choose between deciding to miss optimizations because LLVM thinks the other 7 bits might be used vs. missing optimizations because no one optimized for doing what makes sense.
1
8
Replying to and
I think that's the right approach. I expect that you're missing a lot of optimizations though. First class aggregates are similar. The way Clang does thinks makes it inherently harder to optimize and it does miss optimizations because of it but not as much as doing things sanely.
1
Higher-level languages could make heavy usage of noalias metadata for anything they know is immutable or only used through a single reference. It's defined based on memory dependencies, not pointer equality. Hardly anyone uses restrict so it has historically been broken in LLVM.
1
4
And then, since that's largely unavailable in C, optimizations have not been written to take advantage of it. I can fully understand why a language would reinvent the wheel when they have to make their own IR for optimization anyway and then LLVM botches low-level optimization.
6