diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2021-10-06 14:26:50 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2021-10-08 10:33:47 +0200 |
| commit | 61c5a6d644e9e5c1995c33a2b07ab251702848ac (patch) | |
| tree | 93c2b39cbee9f402ed601add17bd61b4e3c82e2d /src/test/codegen | |
| parent | a4797664ba9c7d71e586122853858eeb6c153bb9 (diff) | |
| download | rust-61c5a6d644e9e5c1995c33a2b07ab251702848ac.tar.gz rust-61c5a6d644e9e5c1995c33a2b07ab251702848ac.zip | |
Create more accurate debuginfo for vtables.
Before this commit all vtables would have the same name "vtable" in debuginfo. Now they get a name that identifies the implementing type and the trait that is being implemented.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/debug-vtable.rs | 47 | ||||
| -rw-r--r-- | src/test/codegen/vtabletype.rs | 21 |
2 files changed, 47 insertions, 21 deletions
diff --git a/src/test/codegen/debug-vtable.rs b/src/test/codegen/debug-vtable.rs new file mode 100644 index 00000000000..851d68da5ee --- /dev/null +++ b/src/test/codegen/debug-vtable.rs @@ -0,0 +1,47 @@ +// compile-flags: -Cdebuginfo=2 -Copt-level=0 -Ccodegen-units=1 +// ignore-tidy-linelength + +// This test checks the debuginfo for the expected 3 vtables is generated for correct names and number +// of entries. + +// NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as debug_vtable::SomeTrait>::{vtable}" +// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, debug_vtable::SomeTrait>::vtable$" +// NONMSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()", +// MSVC: !DIDerivedType(tag: DW_TAG_pointer_type, name: "ptr_const$<tuple$<> >", +// CHECK: !DISubrange(count: 5 + +// NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as debug_vtable::SomeTraitWithGenerics<u64, i8>>::{vtable}" +// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, debug_vtable::SomeTraitWithGenerics<u64,i8> >::vtable$" +// CHECK: !DISubrange(count: 4 + +// NONMSVC-LABEL: !DIGlobalVariable(name: "<debug_vtable::Foo as _>::{vtable}" +// MSVC-LABEL: !DIGlobalVariable(name: "impl$<debug_vtable::Foo, _>::vtable$" +// CHECK: !DISubrange(count: 3 + +#![crate_type = "lib"] + +pub struct Foo; + +pub trait SomeTrait { + fn method1(&self) -> u32; + fn method2(&self) -> u32; +} + +impl SomeTrait for Foo { + fn method1(&self) -> u32 { 1 } + fn method2(&self) -> u32 { 2 } +} + +pub trait SomeTraitWithGenerics<T, U> { + fn method1(&self) -> (T, U); +} + +impl SomeTraitWithGenerics<u64, i8> for Foo { + fn method1(&self) -> (u64, i8) { (1, 2) } +} + +pub fn foo(x: &Foo) -> (u32, (u64, i8), &dyn Send) { + let y: &dyn SomeTrait = x; + let z: &dyn SomeTraitWithGenerics<u64, i8> = x; + (y.method1(), z.method1(), x as &dyn Send) +} diff --git a/src/test/codegen/vtabletype.rs b/src/test/codegen/vtabletype.rs deleted file mode 100644 index 82d65b101b0..00000000000 --- a/src/test/codegen/vtabletype.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This test depends on a patch that was committed to upstream LLVM -// after 5.0, then backported to the Rust LLVM fork. - -// ignore-windows -// ignore-macos - -// compile-flags: -g -C no-prepopulate-passes - -// CHECK-LABEL: @main -// CHECK: {{.*}}DICompositeType{{.*}}name: "vtable",{{.*}}vtableHolder:{{.*}} - -pub trait T { -} - -impl T for f64 { -} - -pub fn main() { - let d = 23.0f64; - let td = &d as &T; -} |
