[llvm-dev] [DWARF] .debug_loc tracking of variable location

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 25 11:20:54 PDT 2018


Hi Victor,

> On Sep 25, 2018, at 10:29 AM, Victor Leschuk via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hello all, could someone point me in the right direction? I am not completely sure I understand the process of tracking variable location (I mean in LLVM code). When we are transforming IR to machine-specific code and assembly how do we exactly track the location of a variable (in terms of .debug_loc section). At which classes/functions should I look?

I’m not very familiar with the backend, but hopefully you’ll find these notes useful (& perhaps others can chime in with corrections).

There’s an analysis called LiveDebugVariables which plays an important role in tracking locations for debug values. It’s invoked both before and after register allocation (see VirtRegRewriter). Before RA, it builds a location list (a map from PC ranges to registers or stack slots) for every debug variable. During RA, these location lists are updated: vregs are mapped to physical ones/killed/copied etc. After RA, LiveDebugVariables inserts DBG_VALUE instructions into the program in a way that (should) accurately & completely convey the information in its location lists.


> To be more specific: I am trying to debug https://bugs.llvm.org/show_bug.cgi?id=38714 but currently I am kind of stuck.

I haven’t looked at this too closely, but I think it’d be worth looking at the output from `-debug-only=livedebugvars`. Why isn’t the location list of `argc` split when it’s moved to w22? Where is that copy introduced, and is that code updating the LDV analysis correctly?

vedant


> 
> -- 
> Best Regards,
> 
> Victor Leschuk | Software Engineer | Access Softek
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list