[LLVMdev] Getting debug information w/ optimizations

Marc de Kruijf dekruijf at cs.wisc.edu
Thu Apr 10 10:09:22 PDT 2008


I am trying to build a bytecode file with optimizations and debug
information using llvm-gcc.  Compiling with "-g" works fine, but when
I add the optimizations flag, all debug information disappears.

On the other hand, if I first "-emit-llvm" with "-g" and no
optimizations, and then apply "opt -std-compile-opts", then debug
information seems to be preserved.

I have two questions:
1)  The "Source Level Debugging with LLVM" documentation page states
the following:  "Compiling a program with "-O3 -g" gives you full
debug information that is always available and accurate for reading
[...]"  Is this incorrect or am I missing something?  What is causing
the debug info to be wiped?
2)  Are the llvm-gcc -O levels (e.g. -O1, -O2, etc.) approximately
equivalent to the regular gcc -O levels, or are they really quite
different?  I couldn't find any recent discussion on this in the
archives.

Many thanks,
Marc



More information about the llvm-dev mailing list