News for hackers. Stuff that matters.
Re:Gollvm from Google by pm90 on Saturday May 27, 2017 @11:43AM (#14430541)
So question for llvm devs here: what benefit does this provide? How does it enhance go? Does it make go programs compile into more efficient binaries targeted to specific cpu architectures?
Re:Gollvm from Google by zeusk on Saturday May 27, 2017 @12:39PM (#14430767)
A big problem intermediate code solves is that, you don't need a big monolithic compiler for both front-end language parsing and back-end architecture instructions. They call it MxN problem, so instead of MxN combinations of architectures and languages in a monolithic compiler - you get M+N components where M handle the language parsing etc.. while N handle the conversion from the single intermediate language/instructions to the target architecture's instructions.
Re:Gollvm from Google by weberc2 on Saturday May 27, 2017 @01:21PM (#14430945)
Go already has its own intermediate representation to solve this problem, so this project must solve some other problem.
Re:Gollvm from Google by krylon on Saturday May 27, 2017 @01:35PM (#14430998)
Better optimizations? AFAIR, the go compiler does some optimizations, but it does not bend over backwards, exactly. Maybe hooking up to llvm can help with that, if it is a goal. (Mmmh, does LLVM optmize at all, or does it just provide a framework for people trying to build optimizing compilers? I don't really know.)

Also, llvm by now reaches far more platforms than the current go compiler. I think that this is the most likely explanation.

Re:Gollvm from Google by kibwen on Saturday May 27, 2017 @01:52PM (#14431069)
But gccgo already exists, and provides an optimizing compiler backend and extended platform support. And the tools in LLVM's ecosystem seem largely useless to Go (no need for asan et al when you have a GC, and no need for tsan when Go already has an optional race detector). Other than the compiler itself having a permissive license, I see no urgent impetus for an LLVM backend for Go, which likely explains why it's taking so long coming.
Re:Gollvm from Google by cyphar on Saturday May 27, 2017 @09:42PM (#14432747)
> But gccgo already exists, and provides an optimizing compiler backend and extended platform support.

We (SUSE / openSUSE) had an incredible amount of issues with gccgo. The main problem was that the runtime wasn't updated often enough, they had some odd patches that broke the runtime, and you generally had to update the compiler to update the Go version (quite difficult in enterprise distributions).

Re:Gollvm from Google by kibwen on Saturday May 27, 2017 @10:25PM (#14432861)
Wouldn't you have those same problems with an LLVM-based backend? LLVM moves very quickly, and AFAICT upgrades are non-trivial.
Re:Gollvm from Google by cyphar on Sunday May 28, 2017 @06:28AM (#14433808)
The problem wasn't the code generation, it's that it was maintained in a way that made it very difficult to update in distributions. They also broke the stdlib in a few versions. But even if you ignore all of that, if it was supported by upstream then we would have more fate in it than using a franken-compiler. ;)
Re:Gollvm from Google by pcwalton on Saturday May 27, 2017 @05:01PM (#14431963)
LLVM has better support for moving GC, due to Azul's efforts. That's a big difference.
Re:Gollvm from Google by kibwen on Saturday May 27, 2017 @10:32PM (#14432875)
Doesn't gccgo reuse the standard Go runtime, and wouldn't integrating LLVM'S GC support require pretty much writing a brand-new runtime?
Re:Gollvm from Google by pcwalton on Sunday May 28, 2017 @03:50AM (#14433487)
LLVM doesn't come with a garbage collector; it comes with hooks you can plug your GC into. So it'd require a good bit of work to integrate with LLVM's GC support, but nowhere near rewriting the whole runtime.
Re:Gollvm from Google by wyldfire on Saturday May 27, 2017 @09:23PM (#14432697)
Go having its own intermediate representation "solves" the problem but requires go-specific backends/lowering mechanisms. LLVM is arguably a more generic place for backends to live. (though in practice it does serve clang's needs best).

If you design a new processor, you generally take it upon yourself to do the work necessary for folks to use C compilers that target your processors. I'd argue that they're more likely to contribute a backend implementation to LLVM than golang.

Re:Gollvm from Google by weberc2 on Saturday May 27, 2017 @10:14PM (#14432837)
I don't disagree, but that's a different problem than the one discussed above. :)
Re:Gollvm from Google by ndesaulniers on Saturday May 27, 2017 @05:43PM (#14432104)
But go ir != llvm ir. The idea is you can leave behind optimizations passes and backend, simply maintaining a frontend, when you adopt the llvm ir and toolchain.
Re:Gollvm from Google by weberc2 on Saturday May 27, 2017 @10:16PM (#14432841)
I don't disagree, but this is a different problem than the one cited above.
Re:Gollvm from Google by zeusk on Sunday May 28, 2017 @11:03AM (#14434628)
well, it is - because the existing architectural backends for llvm ir won't work with go's ir.
Re:Gollvm from Google by weberc2 on Sunday May 28, 2017 @03:12PM (#14435663)
The cited problem was abstracting over different architectures. Go's IR solves this problem already. Solving this problem has nothing to do with making LLVM IR and Go's IR interoperable. A related problem might be that Go's IR doesn't target as many platforms as LLVM's, but that's still a different problem.
Re:Gollvm from Google by jen20 on Sunday May 28, 2017 @08:12AM (#14434075)
Hopefully following the system ABI on AMD64 instead of passing arguments and return values on the stack, though I guess it's to be seen what happens with multiple return values.