just made CXXRTL 20% faster overall (2× faster commits) on clang-11 by replacing a bunch of `flag |= x.commit()` with `if (x.commit()) flag = true;` (gcc-10 is unaffected)
compilers🤦♀️
There are missed optimizations from Clang implementing bool as i8 instead of i1. Range metadata (https://llvm.org/docs/LangRef.html#range-metadata…) is supposed to help with this but doesn't work very well and gets stripped out by transformations. LLVM itself is better at this. Not sure why Clang uses i8.
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.
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.