Hacker News new | ask | show | jobs
by astrange 1442 days ago
Would be interesting to compare with gcc, which has a better implementation of both inlining and register allocation.
3 comments

Define "better".

I'm very familiar with both inlining and register allocation in GCC (I even helped write one of the register allocation rewrite attempts, until vlad went even further down the rabbit hole of writing register allocators than we did)

RA was itself is historically more advanced in amount of optimization it does itself in GCC, but was still mostly a wash, because it's still much easier to work with LLVM's form and better optimizers were written.

LLVM also nowadays has a fairly advanced register allocator if you want it (PBQP) - it produces near optimal register allocations. It's not used though. It hasn't been worth it.

Inlining, they are not usefully comparable - they are very different approaches, both are good, and during the last inliner rewrite in LLVM, large amounts of comparisons were done a large number of times, and there isn't anything to suggest that GCC's inliner is really better (unlike RA, where the default GCC algorithm is certainly more advanced than the default LLVM RA, despite this being a deliberate decision).

We spent a lot of time optimizing inlining and RA/etc code when we transitioned to LLVM at Google (many years ago now)

At when we made that transition it was a net positive thing for fleet, and it was on a very large codebase.

The truth about compilers is there are no silver bullets. Things get faster mostly through careful tuning (which ML will hopefully replace), and much more rarely due to better algorithms.

As a result, i would expect GCC to not do any better here than LLVM.

I still want to see the estimated distance heuristic (https://dspace.library.uvic.ca/bitstream/handle/1828/7107/Bu...) in a modern compiler.
Variants of this have been tried. What are you hoping for?
> Variants of this have been tried

Have a link?

Honestly, no, because it's been decades at this point.

While not as formally written down, this is the most common way that profiling info was ever used in RA.

Using both the execution frequency and use distance to calculate which registers should be spilled and where to spill them was done even in toy research compilers when I was heavy into this part of the world.

I remember seeing implementations in IBM's XLC, at least two of the RA's we implemented in GCC did this, etc.

The thing is that GCC successfully shot its own head off via Stallman so no one cares about doing research with it anymore.

The licence doesn't help but most of this work is open source anyway

What do you mean about GCC shooting itself in the head?

What do you mean about its license?

GCC was for many years designed to be hard to work on/with => LLVM steals it's lunch

GCC is under the GPLv3. This does not bother me so much combined with the former it's bad for getting corporations to spend money on you

Stallman hasn't been relevant to GCC in 10-15 years. If people aren't doing research projects with it, it's because they don't like the code style (which is still weird but not monolithic) or their funders aren't using it in production.
Ten years ago is exactly when LLVM came of age and GCC should've been adapting (which it did in some ways, but remained weird and Stallman-y)
https://gcc.gnu.org/legacy-ml/gcc/2005-11/msg00888.html

> This code is licensed under a BSD-like license [8], and LLVM itself will not initially be assigned to the FSF. If people are seriously in favor of LLVM being a long-term part of GCC, I personally believe that the LLVM community would agree to assign the copyright of LLVM itself to the FSF and we can work through these details.

The leads of the project offered LLVM to the FSF and the offer was ignored because of Stallman's incompetent approach to email.

https://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00...

GCC's irrelevance and LLVM's dominance of the field are definitely his fault (even if there are other factors involved.)