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?
Gollvm from Google
11–20 of 51 posts
Re: Gollvm from Google
#12"At the moment llvm-goparse is not capable of building the Go libraries + runtime (libgo), which makes it difficult/unwieldy to use for running actual Go programs. As an interim workaround, I've written a shim/wrapper script that allows you to use llvm-goparse in combination with an existing GCCGO installation, using gccgo for the runtime/libraries and the linking step, but llvm-goparse for any compilation." Not sure…
See the factorial example, where they build up some LLVM IR (in memory) for computing factorials: https://github.com/go-llvm/llvm/blob/master/examples/factori...
I'd guess the advantage of this is using LLVM's JIT at runtime.
Re: Gollvm from Google
#13> define hidden i64 @foo.bar() { > entry: > %"$ret0" = alloca i64 > store i64 0, i64* %"$ret0" > store i64 1, i64* %"$ret0" > %"$ret0.ld.0" = load i64, i64* %"$ret0" > ret i64 %"$ret0.ld.0" > } Can someone knowledgeable with Go, explain what's happening here? Why does it store a 0 and then a 1 in "$ret0"? Why does it allocate a single integer on the stack? (is it because this is just intermediate code for a virtual m…
Go language semantics define that variables receive a zero initialization.[0]
> and then a 1 in "$ret0"?
The 1 is because the code explicitly stores a 1 :-).
Clearly the output code has not been through an optimization pass.
Re: Gollvm from Google
#14> define hidden i64 @foo.bar() { > entry: > %"$ret0" = alloca i64 > store i64 0, i64* %"$ret0" > store i64 1, i64* %"$ret0" > %"$ret0.ld.0" = load i64, i64* %"$ret0" > ret i64 %"$ret0.ld.0" > } Can someone knowledgeable with Go, explain what's happening here? Why does it store a 0 and then a 1 in "$ret0"? Why does it allocate a single integer on the stack? (is it because this is just intermediate code for a virtual m…
The pass is called mem2reg:
http://llvm.org/docs/Passes.html#mem2reg-promote-memory-to-r...
[1] https://en.wikipedia.org/wiki/Static_single_assignment_form
Re: Gollvm from Google
#15So 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?
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/instruc…
Re: Gollvm from Google
#16Earlier quoted context omitted.
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/instruc…
Go already has its own intermediate representation to solve this problem, so this project must solve some other problem.
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
#17Earlier quoted context omitted.
Go already has its own intermediate representation to solve this problem, so this project must solve some other problem.
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 mo…
Re: Gollvm from Google
#18Re: Gollvm from Google
#19I am somewhat confused by this. The LLVM project already has an official Go frontend that lowers to LLVM IR: * https://llvm.org/svn/llvm-project/llgo/trunk/README.TXT
Re: Gollvm from Google
#20I am somewhat confused by this. The LLVM project already has an official Go frontend that lowers to LLVM IR: * https://llvm.org/svn/llvm-project/llgo/trunk/README.TXT
Does Google think they can do a better job?
1. The maintainer of llgo is a Google employee (and a very talented LLVM engineer).
2. I don't imagine there would be tremendous differences in the strategies used to generate LLVM IR between the tools. ISTM, if there are deficiencies in llgo, then it would be better to fix them rather than creating a whole new tool.