News for hackers. Stuff that matters.
Re:Performance patches in Go 1.11 by MaxBarraclough on Friday June 22, 2018 @08:40AM (#17373482)
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!

Re:Performance patches in Go 1.11 by masklinn on Friday June 22, 2018 @08:53AM (#17373566)
LLVM 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

Re:Performance patches in Go 1.11 by m_sahaf on Friday June 22, 2018 @09:05AM (#17373629)
To 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

- (2014) https://news.ycombinator.com/item?id=8817990

Re:Performance patches in Go 1.11 by pjmlp on Friday June 22, 2018 @09:30AM (#17373780)
I 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.

Re:Performance patches in Go 1.11 by masklinn on Friday June 22, 2018 @09:37AM (#17373827)
Seems 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.
Re:Performance patches in Go 1.11 by pjmlp on Friday June 22, 2018 @10:32AM (#17374210)
Agreed, maybe I expressed myself badly, but that was still kind of my point.
Re:Performance patches in Go 1.11 by MaxBarraclough on Friday June 22, 2018 @10:20AM (#17374130)
Informative comment, thanks.

I was so sure it used LLVM!

Re:Performance patches in Go 1.11 by pjmlp on Friday June 22, 2018 @09:16AM (#17373698)
Go 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.

Re:Performance patches in Go 1.11 by oblio on Friday June 22, 2018 @08:46AM (#17373517)
Go doesn't use LLVM as far as I know.