Switch -g disables optimizations.

David Nadlinger via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Oct 9 00:24:05 PDT 2015


On 9 Oct 2015, at 7:46, Joakim via digitalmars-d-ldc wrote:
> On Friday, 9 October 2015 at 04:22:51 UTC, Marco Leise wrote:
>> push   rbp
>> mov    rbp,rsp
>> xor    eax,eax
>> pop    rbp
>> ret
> Optimization is turned off in debug mode, with a comment claiming 
> debug info doesn't work with optimization:
>
> https://github.com/ldc-developers/ldc/blob/9d3dd1f609e08f001aeec2cacb1c55707f37884b/gen/optimizer.cpp#L179

We should actually look into re-enabling that. I don't know the story 
behind that comment, and I'm not sure who does.

In this particular case, though, the reason for the "ugly" codegen is 
that LDC enables -disable-fp-elim (the equivalent of GCC's 
-fno-omit-frame-pointer) by default when -g is passed. I suppose the 
reason for this was that all the druntime backtracing code (inherited 
from DMD) relies on a full call frame being set up for each function.

  — David



More information about the digitalmars-d-ldc mailing list