summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-11-08 22:04:43 +0000
committerAdrian Prantl <aprantl@apple.com>2017-11-08 22:04:43 +0000
commita8e56458e6689c25e647664ea9d9c09459a0ade9 (patch)
tree36c3e066bcd397b2b97a42861b4dca585b455028 /llvm/lib
parent2c74fe977daf8d1d4c8b64cdd6d3a9999a4b4655 (diff)
downloadbcm5719-llvm-a8e56458e6689c25e647664ea9d9c09459a0ade9.tar.gz
bcm5719-llvm-a8e56458e6689c25e647664ea9d9c09459a0ade9.zip
Let replaceVTableHolder accept any type.
In Rust, a trait can be implemented for any type, and if a trait object pointer is used for the type, then a virtual table will be emitted for that trait/type combination. We would like debuggers to be able to inspect trait objects, which requires finding the concrete type associated with a given vtable. This patch changes LLVM so that any type can be passed to replaceVTableHolder. This allows the Rust compiler to emit the needed debug info -- associating a vtable with the concrete type for which it was emitted. This is a DWARF extension: DWARF only specifies the meaning of DW_AT_containing_type in one specific situation. This style of DWARF extension is routine, though, and LLVM already has one such case for DW_AT_containing_type. Patch by Tom Tromey! Differential Revision: https://reviews.llvm.org/D39503 llvm-svn: 317730
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp5
-rw-r--r--llvm/lib/IR/DIBuilder.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 784a1d512c1..ce7465910fc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -960,8 +960,9 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
// This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
// inside C++ composite types to point to the base class with the vtable.
- if (auto *ContainingType =
- dyn_cast_or_null<DICompositeType>(resolve(CTy->getVTableHolder())))
+ // Rust uses DW_AT_containing_type to link a vtable to the type
+ // for which it was created.
+ if (auto *ContainingType = resolve(CTy->getVTableHolder()))
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
*getOrCreateTypeDIE(ContainingType));
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 18979a8d5cf..837b1ec5857 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -874,7 +874,7 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(
}
void DIBuilder::replaceVTableHolder(DICompositeType *&T,
- DICompositeType *VTableHolder) {
+ DIType *VTableHolder) {
{
TypedTrackingMDRef<DICompositeType> N(T);
N->replaceVTableHolder(VTableHolder);
OpenPOWER on IntegriCloud