[LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0

Martijn martijn at martijnrutten.com
Fri Nov 13 04:52:28 PST 2009


Hello,

I use llvm and llvm-gcc as a C-to-C transformation tool using a
modified version of the c backend, and rely on llvm debug instructions
to link back to the original source code.

Does anyone know how to get detailed line number and variable debug
information at optimization levels beyond O0?

Currently, I extract this debug information by compiling with -g.
This works fine with "llvm-gcc -g -O0 --emit-llvm", i.e. no
optimizations, but when I enable optimizations, e.g. "llvm-gcc -g -O2
--emit-llvm",
most of the dbg.stoppoint and dbg.declare instructions dissapear.

I tried to enable at least debug.declare instructions by removing the
"if(optimize) return" statement in gcc/llvm-debug.cpp,
DebugInfo::EmitDeclare(), but I still do not get any dbg.declare
instructions.

Is there a way to keep all debug information with optimizations
enabled in llvm-gcc?
If I have to disable some specific optimizations to keep the debug
info correct that is fine.

Thanks!
  Martijn

-------------
Martijn Rutten
martijn at martijnrutten.com



More information about the llvm-dev mailing list