Reputation: 2973
I'm developing a frontend of LLVM IR, and want to attach debug information. I already made the %llvm.dbg.declare works, it can track my variable after this declaration. But I do not understand the another %llvm.dbg.value's purpose, can anyone tell me what situation I should use it? or any examples?
Upvotes: 5
Views: 2782
Reputation: 273366
llvm.dbg.declare
is sufficient if you're building your code without optimizations (which you should really do). In non-optimized code, locals live on the stack (in alloca
s) and llvm.dbg.declare
tells the debugger where to find them
When trying to debug optimized code, things get murkier because locals can be in registers and there's no actual "memory location" the debugger can examine to always know the value of a local. This is where llvm.dbg.value
comes in - it can explicitly notify the debugger that a local has changed, and its new value.
Upvotes: 7