Switch -g disables optimizations.

Marco Leise via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu Oct 8 21:22:40 PDT 2015


I found the root for the horrible codegen with ldc2 I was
experiencing. As soon as I added -g to get some line numbers
in disassemblies, one or more optimizations steps got disabled.

  int main(string[])
  {
    return 0;
  }

compiles with -O to:

  xor eax,eax
  ret

and with -O -g to:

  push   rbp
  mov    rbp,rsp
  xor    eax,eax
  pop    rbp
  ret    

ldc2 -version:
LDC - the LLVM D compiler (0.16.0):
  based on DMD v2.067.1 and LLVM 3.6.2

Is that expected to improve the debugging experience and make
local variables always available or a bug? clang's codegen is
not influenced in this way by the -g flag.

-- 
Marco



More information about the digitalmars-d-ldc mailing list