gdc in Linux distros recommended?

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 19 14:28:02 PDT 2016


On 19 October 2016 at 21:25, TheGag96 via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Wednesday, 19 October 2016 at 03:29:10 UTC, Marco Leise wrote:
>>
>> On the other hand LDC subjectively offers a couple more D specific
>> enhancements, like turning GC allocations into stack allocations in trivial
>> cases
>
>
> Whoa, seriously? I know it's a bit off-topic, but do you have a code example
> of where this would happen? That's amazing!
>

Not to be the one to downplay something.  But it's actually pretty boring. ;-)

An example in GDC would be where a closure was created, but the
nesting function was inlined or optimized away.

In the latter case, you may see something like the following in the DCE pass.

int foo()
{
  closure = _d_allocmemory (8);
  closure.bar = 0;

  return 0;
}

Using a mixture of having a closure that is set but never read, and
giving the optimizer the right hints about what "allocmemory" does
means that it removes the call as dead code.

The exact same is done in the former case, you just convert the
closure to a stack frame, removing the dead call the allocmemory.


More information about the Digitalmars-d mailing list