From f3a9150324c4fe88b7f9e28be18e0f989dff8af7 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Tue, 5 Feb 2019 19:33:47 +0000 Subject: [DEBUG_INFO][NVPTX] Generate DW_AT_address_class to get the values in debugger. Summary: 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 DW_OP_swap DW_OP_xderef`. The patch tries to find all such expressions and transform them into `DW_AT_address_class ` if target is NVPTX and the debugger is gdb. If the expression is not found, then default values are used. For the local variables is set to ADDR_local_space(6), for the globals is set to ADDR_global_space(5). The values are taken from the table in the same section 5.2. CUDA-Specific DWARF Definitions. Reviewers: echristo, probinson Subscribers: jholewinski, aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D57157 llvm-svn: 353203 --- llvm/include/llvm/IR/DebugInfoMetadata.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/include') diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 40e6873eba7..385f6e7a65f 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2510,6 +2510,12 @@ public: /// return true with an offset of zero. bool extractIfOffset(int64_t &Offset) const; + /// Checks if the last 4 elements of the expression are DW_OP_constu DW_OP_swap DW_OP_xderef and extracts the . + static const DIExpression *extractAddressClass(const DIExpression *Expr, + unsigned &AddrClass); + /// Constants for DIExpression::prepend. enum { NoDeref = false, WithDeref = true, WithStackValue = true }; -- cgit v1.2.3