3 ms·
So let's assume we mean C as a target, in the way one might target LLVM IR. What LLVM IR offers over C11 or C20 is a great deal more tools to describe to the co
by dleslie 3y ago
So let's assume we mean C as a target, in the way one might target LLVM IR. What LLVM IR offers over C11 or C20 is a great deal more tools to describe to the compiler how one might engage in micro-optimizations.
Ie, linkage[0], lifetime[1], and ordering[2] information can be critical to delivering performance.
Now that said, GCC is _pretty damned amazing_ at squeezing out this information from C, and it's available for use just about everywhere. But it's good at figuring it out for _hand-written_ C. The sort of C that's generated as a compilation output from other languages, like Chicken Scheme and Nim, may not be written in a way that allows the C compiler to fully take advantage of its optimization abilities.
What I find with generated C is that it often is prone to blowing the stack or missing cache far more than hand-written C would. There's often something funky happening (Cheney-on-the-MTA) or it's a soup of function pointers and object references scattered haphazardly across memory.
0: https://llvm.org/docs/LangRef.html#linkage-types https://llvm.org/docs/LangRef.html#linkage-types
1: https://llvm.org/docs/LangRef.html#object-lifetime https://llvm.org/docs/LangRef.html#object-lifetime
2: https://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations https://llvm.org/docs/LangRef.html#memory-model-for-concurre...
- elcritch 3y ago> What I find with generated C is that it often is prone to blowing the stack or missing cache far more than hand-written C would. There's often something funky happening (Cheney-on-the-MTA) or it's a soup of function pointers and object references scattered haphazardly across memory. Definitely a possibility. Nim does pretty well since it has concepts of stack values in addition to ref's unlike perhaps Chicken Scheme or others. Add in that the Nim compiler can do some large scale optimizations that are hard to do in had written C it can perform as well (or better!) than C with some work. Though it's easy to loose performance too if you're sloppy.