diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-11-08 22:04:43 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-11-08 22:04:43 +0000 |
commit | a8e56458e6689c25e647664ea9d9c09459a0ade9 (patch) | |
tree | 36c3e066bcd397b2b97a42861b4dca585b455028 /llvm/unittests/IR/MetadataTest.cpp | |
parent | 2c74fe977daf8d1d4c8b64cdd6d3a9999a4b4655 (diff) | |
download | llvm-a8e56458e6689c25e647664ea9d9c09459a0ade9.zip llvm-a8e56458e6689c25e647664ea9d9c09459a0ade9.tar.gz llvm-a8e56458e6689c25e647664ea9d9c09459a0ade9.tar.bz2 |
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/unittests/IR/MetadataTest.cpp')
-rw-r--r-- | llvm/unittests/IR/MetadataTest.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp index 3ab0ad4..76c1903 100644 --- a/llvm/unittests/IR/MetadataTest.cpp +++ b/llvm/unittests/IR/MetadataTest.cpp @@ -1314,6 +1314,11 @@ TEST_F(DICompositeTypeTest, replaceOperands) { EXPECT_EQ(nullptr, N->getVTableHolder()); N->replaceVTableHolder(VTableHolder); EXPECT_EQ(VTableHolder, N->getVTableHolder()); + // As an extension, the containing type can be anything. This is + // used by Rust to associate vtables with their concrete type. + DIType *BasicType = getBasicType("basic"); + N->replaceVTableHolder(BasicType); + EXPECT_EQ(BasicType, N->getVTableHolder()); N->replaceVTableHolder(nullptr); EXPECT_EQ(nullptr, N->getVTableHolder()); |