LDC 0.15.0 alpha1 released! Please help test!

Kai Nacke via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Oct 24 09:28:12 PDT 2014


Hi Kiith-Sa!

On Friday, 24 October 2014 at 00:50:51 UTC, Kiith-Sa wrote:
> On Wednesday, 22 October 2014 at 18:28:44 UTC, Kai Nacke wrote:
>> Hi everyone!
>>
>> On behalf of the LDC team I am proud to announce the LDC 0.15.0
>> alpha1 release!
>> It is based on the 2.066.1-rc2 front-end and LLVM 3.1-3.5 (OS
>> X: no support for 3.3).
>
>
> I tried it with a project I'm working on, compilation works OK, 
> but I'm getting extremely bad performance (50-100x overhead 
> compared to DMD) - profiling has shown that some code that 
> should execute at compile-time seems to run at run-time.
>
> I never used LDC before, I don't know if this is a bug or I'm 
> doing something wrong - I'm using LDC through DUB, so I didn't 
> specify command-line args directly. (tried both debug and 
> release builds, but args were passed by DUB)

Thanks for trying LDC!

CTFE is done in the frontend therefore there should be no 
difference between LDC and DMD. But a bug can always creep in...

> Can't publish the project (yet), but here's a part of a 
> function annotated by the profiler (perf):

We really prefer reduced test cases. :-) If you can produce one 
that would be really great.

>
>       bool matchComponents(ComponentTypeIDs...)()
>       push   %rbp
>       mov    %rsp,%rbp
>         {
>             // Type IDs of processed component types.
>             enum processedIDs = 
> componentIDs!ProcessedComponents;
>       sub    $0x70,%rsp
>       mov    $0x68dae0,%eax
>       mov    %eax,%ecx
>       mov    $0x4,%eax
>       mov    %eax,%esi
>       mov    %rdi,-0x40(%rbp)
>       mov    %rcx,%rdi
>     → callq  _d_newarrayU
>       movw   $0x28,0x6(%rdx)
>       movw   $0x25,0x4(%rdx)
>       movw   $0x21,0x2(%rdx)
>       movw   $0x1,(%rdx)
>             enum sortedIDs = 
> std.algorithm.sort([ComponentTypeIDs]);
>       mov    $0x68e210,%r8d
>       mov    %r8d,%edi
>       mov    $0x3,%r8d
>       mov    %r8d,%esi
>       mov    %rax,-0x48(%rbp)
>     → callq  _d_newarrayU
> .. etc
>
> Note the _d_newarrayU - it seems the array literal is allocated 
> despite only being used at compile-time? On the other hand, 
> sort() doesn't seem to be called.
>
>
> Same function with DMD (the 'enum' lines don't even show up):
>
>       /// Determine if the current entity contains specified 
> component types.
>       bool matchComponents(ComponentTypeIDs...)()
>       push   %rbp
>       mov    %rsp,%rbp
>       sub    $0x18,%rsp
>       push   %rbx
>       mov    %rdi,-0x8(%rbp)
>       mov    -0x8(%rbp),%rax
>       mov    (%rax),%rcx
>       lea    0x358(%rax),%rdx
>       cmp    (%rdx),%rcx
>     ↓ jb     2a
>       mov    $0x1f1,%edi
>     → callq  _D7tharsis6entity11entityrange7__arrayZ
> 2a:   mov    (%rax),%rbx
>       mov    (%rdx),%rax
>       mov    0x8(%rdx),%rdx
>       mov    (%rdx,%rbx,2),%cx
>       neg    %cx
>       sbb    %ecx,%ecx
>       neg    %ecx
>       mov    %cl,-0x10(%rbp)
>                 return parts.join(" && ");
>             }
>
>             // The actual run-time code is here.
>             mixin(q{const result = 
> cast(bool)(%s);}.format(matchCode()));
>             return result;
>       mov    -0x10(%rbp),%al
>         }
>       pop    %rbx
>       leaveq
>     ← retq

I do not use DUB so I don't know which args were passed to LDC. I 
would assume that release only passes the -release switch. Could 
you try it again with a higher optimization level, e.g. -O2 or 
-O3? There is also a problem with the inliner (David gave some 
hints here: 
http://forum.dlang.org/post/ursgarblzengucvxnmfz@forum.dlang.org). 
Using -singleobj with multiple objects might help, too.

Regards,
Kai


More information about the digitalmars-d-ldc mailing list