Martijn
2009-Nov-13 12:52 UTC
[LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
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
Devang Patel
2009-Nov-16 22:16 UTC
[LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
Hi Martijn On Fri, Nov 13, 2009 at 4:52 AM, Martijn <martijn at martijnrutten.com> wrote:> 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.This will enable dbg.declare, but they'll be removed by mem2reg pass immediately.> 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.Without mem2reg pass, you're unlikely to get much optimization done on your IR. We're working on the required support to enable variable debug info at -O1+. http://nondot.org/~sabre/LLVMNotes/DebugInfoVariableInfo.txt Let us know if you'd like to contribute in this area! - Devang
Martijn
2009-Nov-17 11:25 UTC
[LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
Hi Devang,>> 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. > > This will enable dbg.declare, but they'll be removed by mem2reg pass > immediately. > >> 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. > > Without mem2reg pass, you're unlikely to get much optimization done on your IR.Clear, thanks! I presume the mem2reg pass is also essential in the CLang frontend, so CLang is not an alternative to llvm-gcc to keep more debug information? For the dbg.stoppoints: many of the stoppoint instructions dissapear at higher optimization levels. We need these to link back instructions to original C statements. I guess this is not related to the mem2reg pass. Is there a way to at least keep the stoppoint instructions?> > We're working on the required support to enable variable debug info at -O1+. > http://nondot.org/~sabre/LLVMNotes/DebugInfoVariableInfo.txt > Let us know if you'd like to contribute in this area!The llvm.dbg.value proposal looks very interesting. We would like to contribute if possible. I estimate we do not have sufficient llvm experience to contribute ourselves, but may take up a part of the work using a contractor. Can you identify a clear part for which we could hire a contractor? Martijn
Seemingly Similar Threads
- [LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
- [LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
- [LLVMdev] llvm-gcc: missing dbg.declare/dbg.stoppoint at optimization level > O0
- [LLVMdev] debug stoppoint nodes with -fast option
- [LLVMdev] debug stoppoint nodes with -fast option