D generates large assembly for simple function

Seb seb at wilzba.ch
Sun Jan 28 01:11:59 UTC 2018


On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote:
> On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
>> Godbolt link: https://godbolt.org/g/t5S976
> The actual code is :
>  imul edi, edi
>  mov eax, edi
>  ret
>
>
> The rest is runtime initialization.
> which you can remove using an undocumented -betterC switch.

BTW as asm.dlang.org is dead, you can use run.dlang.io for these 
things, e.g.

DMD: https://run.dlang.io/is/lLL1aJ
LDC: https://run.dlang.io/is/sVn5tu

(-output-s / -asm are only added for extra convenience)

Since a couple of days, it even does demangling of the symbols.
Though, of course, if you want to look only at LDC's output, 
godbolt is still the better choice.


More information about the Digitalmars-d-learn mailing list