DWARF location lists

In the version of LLVM I’m using (Apple tag 2352.1), it seems that the DWARF emitter cannot produce DWARF location lists to outline when user variables live and where. Instead it uses a crutch of DW_AT_start_scope to specify each solitary location where an assignment to a user variable does occur.

This is unsatisfactory for machines that put user variables in registers because it doesn’t specify when a register is used for some other purpose, leaving the debugger no clue about when a user’s variable might be “dead”. Instead, the debugger will silently tell the user whatever happens to be in that register at the time.

To do the right thing, I think the register allocator needs to emit llvm.dbg.value calls to specify “undef” as the new value for a variable whenever the register a variable lives in is repurposed. And then the DWARF emitter needs to use the pair of llvm.dbg.value calls to emit a location list if necessary (ie, the variable lives in more than one register during its overall lifetime, or isn’t available for its entire scope.)

Does this sound reasonable? If so, who is active in the DWARF emitter and can help or advise on any relevant changes (since 2352.1, or planned) in this area? It does seem likely to me that this deficiency might have been addressed already, or at least have plans in place.


Richard Relph
MTS | Stream Compute SW | AMD
o. 408.749.6659


It does sometimes for ELF: http://www.llvm.org/bugs/show_bug.cgi?id=9493

But much less often than GCC.


You may want to try with SVN trunk. The DWARF emitter has just learned to notice when registers are clobbered. This did not make it into the 2.9 release.