aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat/Dwarf.cpp
diff options
context:
space:
mode:
authorScott Linder <Scott.Linder@amd.com>2023-05-17 21:33:09 +0000
committerScott Linder <Scott.Linder@amd.com>2023-06-19 21:46:24 +0000
commit58669354bf1f8eef39979e31915b1e212a3985c9 (patch)
tree1ca1f5412bba13488131284731cdbc1692438b1c /llvm/lib/BinaryFormat/Dwarf.cpp
parent4b6d41cd1d73a72403679ec21732df3610fc0964 (diff)
downloadllvm-58669354bf1f8eef39979e31915b1e212a3985c9.zip
llvm-58669354bf1f8eef39979e31915b1e212a3985c9.tar.gz
llvm-58669354bf1f8eef39979e31915b1e212a3985c9.tar.bz2
[DebugInfo] Add DW_OP_LLVM_user extension point
The extension codespace for DWARF expressions (DW_OP_LLVM_{lo,hi}_user) has shrunk over time, as no extension is ever "retired" in practice. To facilitate future extensions, this patch reserves one open opcode as an extension point (0xfe), which is followed by a ULEB128-encoded SubOperation, and then by the subop's operands. There is some prior-art, namely DW_OP_AARCH64_operation (see https://github.com/ARM-software/abi-aa/blob/edd7460d87493fff124b8b5713acf71ffc06ee91/aadwarf64/aadwarf64.rst#45dwarf-expression-operations). This version makes some different tradeoffs, opting to use a ULEB128 for the subop encoding for future-proofing. Reviewed By: #debug-info, dblaikie Differential Revision: https://reviews.llvm.org/D147271
Diffstat (limited to 'llvm/lib/BinaryFormat/Dwarf.cpp')
-rw-r--r--llvm/lib/BinaryFormat/Dwarf.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 12e9c73..e4e5b5d 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -172,6 +172,40 @@ unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
.Default(0);
}
+static StringRef LlvmUserOperationEncodingString(unsigned Encoding) {
+ switch (Encoding) {
+ default:
+ llvm_unreachable("unhandled DWARF operation with LLVM user op");
+#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) \
+ case DW_OP_LLVM_##NAME: \
+ return "DW_OP_LLVM_" #NAME;
+#include "llvm/BinaryFormat/Dwarf.def"
+ }
+}
+
+static unsigned
+getLlvmUserOperationEncoding(StringRef LlvmUserOperationEncodingString) {
+ unsigned E = StringSwitch<unsigned>(LlvmUserOperationEncodingString)
+#define HANDLE_DW_OP_LLVM_USEROP(ID, NAME) .Case(#NAME, DW_OP_LLVM_##NAME)
+#include "llvm/BinaryFormat/Dwarf.def"
+ .Default(0);
+ assert(E && "unhandled DWARF operation string with LLVM user op");
+ return E;
+}
+
+StringRef llvm::dwarf::SubOperationEncodingString(unsigned OpEncoding,
+ unsigned SubOpEncoding) {
+ assert(OpEncoding == DW_OP_LLVM_user);
+ return LlvmUserOperationEncodingString(SubOpEncoding);
+}
+
+unsigned
+llvm::dwarf::getSubOperationEncoding(unsigned OpEncoding,
+ StringRef SubOperationEncodingString) {
+ assert(OpEncoding == DW_OP_LLVM_user);
+ return getLlvmUserOperationEncoding(SubOperationEncodingString);
+}
+
unsigned llvm::dwarf::OperationVersion(dwarf::LocationAtom Op) {
switch (Op) {
default: