An LLVM bug that affect both LDC and SDC. Worth pushing for
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 18 14:29:55 PDT 2014
On Wednesday, 18 June 2014 at 21:22:44 UTC, Iain Buclaw via
Digitalmars-d wrote:
> Likewise here. But unless I'm missing something (I'm not sure
> what
> magic happens with @allocate, for instance), I'm not sure how
> you
> could expect the optimisation passes to squash closures
> together.
>
> Am I correct in that it's asking for:
> ------
> int *i = new int;
> *i = 42;
> return *i;
>
>
> To be folded into:
> ------
> return 42;
That is the final goal. A first goal should be:
int *i = new int;
*i = 42;
return 42;
That first step is supposed to be done by LLVM infra itself (and
it does for such a simple example, but if you multiply the new,
it gets confused). It is necessary because at this point, the
language specific pass will be able to detect that nobody ever
read from the allocated memory and that it doesn't escape, so it
can be optimized away.
If the first step do not happen, then the second step won't
either, and it cascade down to pretty stupid code generation.
More information about the Digitalmars-d
mailing list