Link time optimization in D
Walter Bright
newshound1 at digitalmars.com
Mon May 31 15:41:00 PDT 2010
retard wrote:
> Mon, 31 May 2010 18:23:18 +0200, Pelle wrote:
>
>> On 05/31/2010 05:43 PM, retard wrote:
>>> DMD is much slower than Sun Javac/Jvm 7, GNU GCC 4.5, and LLVM.
>> For very special values of much, I suppose.
>
> Polymorphic method calls, auto-vectorization, link-time optimization,
> floating point performance, etc.
Link time optimization? Let's examine it:
https://lwn.net/Articles/387122/
"When source files are compiled and linked using -flto, GCC applies
optimizations as if all the source code were in a single file. This allows GCC
to perform more aggressive optimizations across files, such as inlining the body
of a function from one file that is called from a different file, and
propagating constants across files. In general, the LTO framework enables all
the usual optimizations that work at a higher level than a single function to
also work across files that are independently compiled."
D has had that for 8 years now, it's just done in the compiler instead of the
linker. You can specify as many D source modules as you want on the command line
to the compiler, and it will compile & optimizer & inline them all together and
generate one object file.
Essentially, link time optimization is a hack to get around the language problem
C/C++ have with their separate compilation model.
To say D code is slower because it lacks link-time optimization is a false
supposition.
More information about the Digitalmars-d
mailing list