summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-02-05 19:33:47 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-02-05 19:33:47 +0000
commitf3a9150324c4fe88b7f9e28be18e0f989dff8af7 (patch)
treedc656043836629adf1ad8f924c64d810c9642314 /llvm/lib/IR
parenta3f9b71c09613fa51df44a6253afc52e5fff2947 (diff)
downloadbcm5719-llvm-f3a9150324c4fe88b7f9e28be18e0f989dff8af7.tar.gz
bcm5719-llvm-f3a9150324c4fe88b7f9e28be18e0f989dff8af7.zip
[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 <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. Reviewers: echristo, probinson Subscribers: jholewinski, aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D57157 llvm-svn: 353203
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 3211a5bb66d..f772276613c 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -928,6 +928,24 @@ bool DIExpression::extractIfOffset(int64_t &Offset) const {
return false;
}
+const DIExpression *DIExpression::extractAddressClass(const DIExpression *Expr,
+ unsigned &AddrClass) {
+ const unsigned PatternSize = 4;
+ if (Expr->Elements.size() >= PatternSize &&
+ Expr->Elements[PatternSize - 4] == dwarf::DW_OP_constu &&
+ Expr->Elements[PatternSize - 2] == dwarf::DW_OP_swap &&
+ Expr->Elements[PatternSize - 1] == dwarf::DW_OP_xderef) {
+ AddrClass = Expr->Elements[PatternSize - 3];
+
+ if (Expr->Elements.size() == PatternSize)
+ return nullptr;
+ return DIExpression::get(Expr->getContext(),
+ makeArrayRef(&*Expr->Elements.begin(),
+ Expr->Elements.size() - PatternSize));
+ }
+ return Expr;
+}
+
DIExpression *DIExpression::prepend(const DIExpression *Expr, bool DerefBefore,
int64_t Offset, bool DerefAfter,
bool StackValue) {
OpenPOWER on IntegriCloud