Ping.

On 22/01/2021 11:42, Andrew Stubbs wrote:
Hi all, Jakub,

I need to implement DWARF for local variables that exist in an alternative address space. This happens for OpenACC gang-private variables (or will when the patches are committed) on AMD GCN, at least.

This is distinct from pointer variables that reference other address spaces, and is currently not supported by either GCC or standard DWARF, I think. It is, apparently, not sufficient or appropriate to add DW_OP_address_class to the DWARF after the variable location definition as that is exclusively for pointers.

There is also the issue that GDB will attempt to relocate all symbols defined with DW_OP_addr, but this is inappropriate for symbols in alternative address spaces as the binary's load address is meaningless there.

AMD have created some DWARF extensions to handle address spaces, and they are already implemented in LLVM. A GDB implementation is in progress.

https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html#amdgpu-dwarf-segment-addresses

A conformant DWARF representation look like this:

DW_TAG_variable
   DW_AT_abstract_origin (0x0000000000000048 "w")
   DW_AT_location (DW_OP_const8u 0x0, DW_OP_constu 0x3,
                   DW_OP_LLVM_form_aspace_address)

That is, at address 0, in address space 3.

The attached patch is clearly not perfect, but does work. It emits the above format for any variable with an address space. For this prototype, I have (ab)used the DTPREL feature to prevent the symbol being relocated. (This port does not use DTPrel for anything else.)

How should I implement this feature to make it acceptable to commit?

Thanks very much

Andrew

Reply via email to