According to
https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf,
the compiler should emit the DW_AT_address_class attribute for all
variable and parameter. It means, that DW_AT_address_class attribute
should be used in the non-standard way to support compatibility with the
cuda-gdb debugger.
Clang is able to generate the information about the variable address
class. This information is emitted as the expression sequence
DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef. The patch
tries to find all such expressions and transform them into
DW_AT_address_class <DWARF Address Space> if target is NVPTX and the debugger is gdb.
If the expression is not found, then default values are used. For the
local variables <DWARF Address Space> is set to ADDR_local_space(6), for
the globals <DWARF Address Space> is set to ADDR_global_space(5). The
values are taken from the table in the same section 5.2. CUDA-Specific
DWARF Definitions.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 27243 Build 27242: arc lint + arc unit
Event Timeline
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | ||
---|---|---|
112 | This should be a member function of DIExpression instead. We have other similar properties there already. | |
113 | This is not general enough. You probably want to check that the last 4 elements of the DIExpression match this pattern instead, since the LLVM optimizer may insert additional operations at the beginning of the Expression at any time. |
Adrian, thanks a lot for the review!
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | ||
---|---|---|
112 | Made it a static member function instead of the DIExpression class. Need to modify the expression by deleting the last 4 elements after AddressClass extraction, but function is applied to const expressions. Need to create the new expression, if the pattern was recognized. |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
2516 ↗ | (On Diff #185348) | I understand that you copied the interface from the function above, but could you please make it Optional<unsigned> getAddressClass() const; instead? We should also change extractIfOffset this way... |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
2516 ↗ | (On Diff #185348) | I cannot make it const, it modifies the expression itself and should build the new expression if the pattern is found. |
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
2516 ↗ | (On Diff #185348) | I mean, it should(!) modify the expression itself, but I can not do it, because this function is applied to the constant expressions. |
This should be a member function of DIExpression instead. We have other similar properties there already.