3 ms·
Looking at Slide 7: doesn't LLVM do function-inlining, presumably with quite well-tuned heuristics? What's the advantage in having the frontend side of the comp
by MaxBarraclough 8y ago
Looking at Slide 7: doesn't LLVM do function-inlining, presumably with quite well-tuned heuristics? What's the advantage in having the frontend side of the compiler doing it too?
Or am I wrong, and does LLVM not do inlining?
Edit: I'm a silly person, Go doesn't use LLVM. I've been wrong about that for some time!
- oblio 8y agoGo doesn't use LLVM as far as I know.
- masklinn 8y agoLLVM does do inlining (it's the most important optimisation you can implement, at least for native codegen), but the reference Go implementation (gc) does not use LLVM, the entire toolchain is custom. On the one hand, that allows very fast compilation & codegen, on the other hand the optimisations are fairly limited. It also doesn't benefit from improvements done by other users, but doesn't saddle you with their issues[0]. There's also a Go implementation on top of GCC (gccgo), however while it generates high-quality code historically it wasn't really better than gc due to lacking escape analysis (so it did a ton more heap allocations than the reference) and having a lackluster GC. [0] Rust has had its own LLVM fork for as long as the project has existed, for both fixing issues it hit which haven't yet been fixed upstream and implementing features it needs which have not been or can not be upstreamed
- m_sahaf 8y agoTo add to your comment, here are Russ Cox's comments on why the toolchain is custom and they didn't use LLVM: - (2010) https://news.ycombinator.com/item?id=1509700 https://news.ycombinator.com/item?id=1509700 - (2014) https://news.ycombinator.com/item?id=8817990 https://news.ycombinator.com/item?id=8817990
- pjmlp 8y agoI am always torn in such approaches, in one way it means throwing away decades of code optimization. On the other hand, in a world that devs only believe in stuff when others actually implement it in production, it is nice to see that their toolchain is self sufficient without the usual C or C++ dependency. Many language designers opt for implementing their toolchains in C or C++ just for mere convinience, and it is ok so. However it creates the wrong perception among those without compiler development knowledge, that C and C++ are the only way to implement a toolchain.
- masklinn 8y agoSeems to me these are orthogonal concerns, LLVM is in C++ but the question I answered was about using LLVM versus implementing a custom toolchain, not implementing a custom toolchain in C++ versus some other language.
- deleted 8y ago[deleted]
- pjmlp 8y agoAgreed, maybe I expressed myself badly, but that was still kind of my point.
- MaxBarraclough 8y agoInformative comment, thanks. I was so sure it used LLVM!
- pjmlp 8y agoGo doesn't use LLVM, so that is kind of moot point. In more sophisticated languages, you might get inlining done multiple times, as some inlining decisions are easier with code knowledge, while others are better when the optimizer only sees IR.