Link time optimization in D
Robert Jacques
sandford at jhu.edu
Fri Jun 4 09:53:38 PDT 2010
On Mon, 31 May 2010 19:09:06 -0400, dsimcha <dsimcha at yahoo.com> wrote:
> == Quote from Walter Bright (newshound1 at digitalmars.com)'s article
>> 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.
>
> I was not aware that specifying multiple files at the same time affects
> optimization. This feature needs to be better integrated into IDEs.
> For small
> but computationally intensive scientific computing programs, I would
> rather ditch
> separate compilation entirely and just compile the entire program in one
> go.
> Nonetheless, CodeBlocks compiles each file separately by default, and if
> this is
> customizable I don't how how.
Includes count for the purposes of this feature, so you shouldn't be
losing any optimization opportunities with separate compilation.
More information about the Digitalmars-d
mailing list