4 ms·
LLVM IR can detect overflow, has exceptions, tail call optimisations etc? I thought it was lower level than C itself. I have kind of a strict hierarchy of abstr
by lacampbell 10y ago
LLVM IR can detect overflow, has exceptions, tail call optimisations etc? I thought it was lower level than C itself. I have kind of a strict hierarchy of abstraction in my head, with LLVM IR sitting a bit below C, but maybe it's not that simple.
- munin 10y agoYes. http://llvm.org/docs/LangRef.html#arithmetic-with-overflow-intrinsics http://llvm.org/docs/LangRef.html#arithmetic-with-overflow-i... http://llvm.org/docs/LangRef.html#exception-handling-intrinsics http://llvm.org/docs/LangRef.html#exception-handling-intrins... http://llvm.org/docs/LangRef.html#call-instruction http://llvm.org/docs/LangRef.html#call-instruction
- int_19h 10y agoSitting below C is exactly what you want in this case. It's not about tail calls as an automatic optimization - it's about having a tailcall opcode of some sort, that guarantees a tail call when used (but you're responsible for lifetimes etc). That is inherently a low-level facility - lower than what the C standard provides. C implementations can do tail calls, but because this behavior isn't actually guaranteed and is purely a quality-of-implementation issue, a language that needs tail calls for its idiomatic code to not blow up the stack cannot target portable C, unless it redoes the stack itself.