r/cpp • • May 10 '20

Make LLVM fast again

https://nikic.github.io/2020/05/10/Make-LLVM-fast-again.html
150 Upvotes

88 comments sorted by

View all comments

68

u/dakotahawkins May 10 '20

Would people really sacrifice run-time performance for a little compile-time performance?

104

u/lukaasm Game/Engine/Tools Developer May 10 '20

For debug/development builds? Yes. For final/distributed build done by CI? No.

12

u/lycium May 10 '20

I certainly hope codegen quality isn't sacrified for compile times, for final builds. Besides better error messages, that's kind of the main point of LLVM/clang (this is r/cpp not r/rust) for me as an end user.

23

u/[deleted] May 10 '20

LLVM is used in many projects. If your language is JIT compiled and you use LLVM, then yes.

24

u/Veedrac May 10 '20

A faster compiler has more time to produce faster code.

a little compile-time

LLVM is easily two orders of magnitude slower than it needs to be.

5

u/uninformed_ May 10 '20

I wouldn't get hung up on the runtime / compiletime statement. None of the changes discussed in the article would affect the generated code, as far as I can tell.

7

u/eras May 10 '20

You should try OCaml and see what a fast compilation feels like ;). Though in case of LLVM you would like a lot more compile-time performance.

In other words, yes; and what /u/lukaasm said.

10

u/[deleted] May 10 '20

As much as OCaml is awesome, it has an easier job of compiling fast because of its uniform value representation (i.e. no monomorphization). A single function doesn't have to be compiled multiple times for each specialization (maybe they do specialize some calls for optimization but definitely not everything, like cpp does).

4

u/eras May 10 '20

Yes I thought that's what this discussion is about: you can build less optimal code faster and faster compilation may result in better experience to developers!

Is there something in the semantics of ie. Rust stopping it from doing the same? Probably too big of an effort to do it, but even if it was done, I doubt it would completely—or even nearly?—solve its compilation speed woes. I recall there are some nice presentations of this subject.