Live data from Hacker News

Golang dev.ssa branch merged into tip

github.com

11–20 of 37 posts

Re: Golang dev.ssa branch merged into tip

#13
post #10
post #4

Earlier quoted context omitted.

It appears it's a new way to do code generation. So any adding of new architectures is dead in the water until this is resolved. https://groups.google.com/forum/#!topic/golang-dev/zz-gWGXFZ...

SSA, once you understand it, is easier to work with than almost all other forms of instruction sets. I'd argue that it would only accelerate new architecture in the long-run. I'm interested in why LLVM was disqualified. Was it simply never considered or is it incompatible with the Go type system, calling convention, etc.?

It's rather easy to add a calling convention to LLVM. If I would have to guess it would be that they thought LLVM was too slow for them. They said from the start compilation speed was a big point for them.

Also LLVM requires you to either write your IR in SSA or add another expensive optimisation pass to make it SSA (mem2reg). Perhaps they thought writing an SSA generator would be too much of a headache.

Re: Golang dev.ssa branch merged into tip

#14
post #2

So... not been closely following development on Go. What does this mean?

Improved optimizations which will also be easier to implement, with the result being faster and also typically smaller code.

And typically longer compile times. Most variables are split into ("phi") variants, for each assignment, and many more costly optimization steps are now possible.

Re: Golang dev.ssa branch merged into tip

#15
post #10
post #4

Earlier quoted context omitted.

It appears it's a new way to do code generation. So any adding of new architectures is dead in the water until this is resolved. https://groups.google.com/forum/#!topic/golang-dev/zz-gWGXFZ...

SSA, once you understand it, is easier to work with than almost all other forms of instruction sets. I'd argue that it would only accelerate new architecture in the long-run. I'm interested in why LLVM was disqualified. Was it simply never considered or is it incompatible with the Go type system, calling convention, etc.?

> I'm interested in why LLVM was disqualified.

They simply used what they knew best:

> If step one had been "learn the GCC or LLVM toolchains well enough to add segmented stacks", I'm not sure we'd have gotten to step two.

> Honestly, if we'd built on GCC or LLVM, we'd be moving so slowly I'd probably have left the project years ago.

https://news.ycombinator.com/item?id=8817990

Re: Golang dev.ssa branch merged into tip

#16
post #13
post #10

Earlier quoted context omitted.

SSA, once you understand it, is easier to work with than almost all other forms of instruction sets. I'd argue that it would only accelerate new architecture in the long-run. I'm interested in why LLVM was disqualified. Was it simply never considered or is it incompatible with the Go type system, calling convention, etc.?

It's rather easy to add a calling convention to LLVM. If I would have to guess it would be that they thought LLVM was too slow for them. They said from the start compilation speed was a big point for them. Also LLVM requires you to either write your IR in SSA or add another expensive optimisation pass to make it SSA (mem2reg). Perhaps they thought writing an SSA generator would be too much of a headache.

The LLVM docs say that clang uses mem2reg for mutable local variables, so it can't be very slow.

From the end of

http://llvm.org/docs/tutorial/LangImpl7.html#memory-in-llvm

> Proven and well tested: clang uses this technique for local mutable variables. As such, the most common clients of LLVM are using this to handle a bulk of their variables. You can be sure that bugs are found fast and fixed early.

Re: Golang dev.ssa branch merged into tip

#17
post #12

Earlier quoted context omitted.

It is the new backend for the Go Compiler See: https://docs.google.com/document/d/1szwabPJJc4J-igUZU4ZKprOr...

So, currently Stage1 is complete. 2 more to go

From the referenced doc:

  I’m not entirely convinced that stages 2 & 3 are
  necessary, maybe we stop at stage 1.  It all depends on
  what optimizations we’d like to do that can’t be done
  because the IR is in the wrong form.  Proceeding with
  stages 2 and 3 might gain some efficiency in the compiler
  itself because then we don’t have to generate the old IR
  at all.  I suspect that effect will be small, however.

Re: Golang dev.ssa branch merged into tip

#18
post #14

Earlier quoted context omitted.

Improved optimizations which will also be easier to implement, with the result being faster and also typically smaller code.

And typically longer compile times. Most variables are split into ("phi") variants, for each assignment, and many more costly optimization steps are now possible.

True, an increase in optimizations will likely mean longer compile times, on the other hand, with better optimized code, the compiler itself (as it's written in Go) will also perform better, which may negate some of the increase in compile time.

Re: Golang dev.ssa branch merged into tip

#19
post #14

Earlier quoted context omitted.

And typically longer compile times. Most variables are split into ("phi") variants, for each assignment, and many more costly optimization steps are now possible.

True, an increase in optimizations will likely mean longer compile times, on the other hand, with better optimized code, the compiler itself (as it's written in Go) will also perform better, which may negate some of the increase in compile time.

One of the alluring things of SSA form is that many optimizations are much faster to execute on the form. The costly part is to raise the SSA form in the first place which in the standard implementation requires one to build a costly dominator tree.

You don't need to add every optimization known to man to a compiler, so you can sometimes keep a few of the important ones and then skip every other optimization. A priori, I'd guess SSA would speed up the compiler, which means you end up having a better budget for the more expensive optimizations.

Re: Golang dev.ssa branch merged into tip

#20
post #10
post #4

Earlier quoted context omitted.

It appears it's a new way to do code generation. So any adding of new architectures is dead in the water until this is resolved. https://groups.google.com/forum/#!topic/golang-dev/zz-gWGXFZ...

SSA, once you understand it, is easier to work with than almost all other forms of instruction sets. I'd argue that it would only accelerate new architecture in the long-run. I'm interested in why LLVM was disqualified. Was it simply never considered or is it incompatible with the Go type system, calling convention, etc.?

In addition to what others said, support for precise garbage collection in LLVM was not ideal at the time. The experimental gc statepoint extension spearheaded by the Azul guys is trying to change that. They've been working on it publicly since late 2014.
Post reply on HN