6 points · by psanchez · 1w ago · 3 comments
So we came up with a solution of translators in between. The app always gets the same payload, and the translators take care of the mapping. Yes, the app shows an empty value, but that's better than a crashing app. If the app crashes, that's a big embarrassment for the company.
We faced another issue with this, as the translators just silently showed empty values and the app worked, but we only came to know when someone complained. The solution was adding logs and alerts, which were sent to the team when any mapping failed.
- Verbosity. LLVM-IR is verbose - a 10-line C/C++ function could easily run to almost 100 lines of LLVM IR. For small functions, eh, it's a minimal cost but for an entire application, that's (a) a lot of tokens, and (b) a huge error-surface
- Problem domain. Traditionally we use a compiler, a dedicated tool, to handle everything at the LLVM IR level, so there's not a lot of training data for the LLM. An LLM doesn't necessarily need too much in the way of training data, if it can reasonably understand the syntax - it generally converts front-end syntax into an internal representation that maps to its internal knowledgebase well to do the reasoning part, and only maps to the desired output format at the end - but the more training data, the less likelihood of hallucination.
- Version skew. LLVM IR is not a particularly stable language, on the scale of actual languages. It's (by definition) an internal representation of the code. There is no contract to keep it static and stable over long periods of time. That's fine for the LLVM compilers themselves, but its an issue if your "language" is changing in undocumented ways underneath you.
- Support. There's no stdlib, no ABI or conventions - you write the whole thing if you're writing at the LLVM level. You need to set up your calling conventions, your structure layouts, varargs, exception handling, memory management practices, even data-layout.
- Undefined behaviour. You might think that it's "easier" because it's lower level, and in some ways it is, but LLVM is a fairly high-level "low-level". LLVM. has poison, undef, nsw/nuw, inbounds, exact etc. etc. LLVM IR that passes the verifier can still exhibit undefined behaviour and be silently miscompiled. Even if it "looks good"
- Lack of debuggability. In a traditional language we expect source-level debugging to map well with the original, and a lot of that comes with the compiler doing its best to maintain that link. LLVM IR isn't particularly readable, and you lose the debugger trail that makes things maintainable.
- Optimisation. Just because something is written in LLVM IR doesn't mean your code runs quickly. There's a lot to optimisation that is about recognising patterns, moving code, and calling appropriate hardware. That is all done right now inside a specialist tool, so the LLM has to do it from scratch, not from knowing "it was done like this before".
Overall I think the cons outweigh the pros by quite a bit. Using an LLM to write a tool to do the optimisation works out better than trying to teach the LLM to write optimised code, at least IMHO. The benchmarks from xc[1] would seem to bear that out.