Rollup merge of #107373 - michaelwoerister:dont-merge-vtables-when-debuginfo, r=WaffleLapkin
Don't merge vtables when full debuginfo is enabled. This PR makes the compiler not emit the `unnamed_addr` attribute for vtables when full debuginfo is enabled, so that they don't get merged even if they have the same contents. This allows debuggers to more reliably map from a dyn pointer to the self-type of a trait object by looking at the vtable's debuginfo. The PR only changes the behavior of the LLVM backend as other backends don't emit vtable debuginfo (as far as I can tell). The performance impact of this change should be small as [measured](https://github.com/rust-lang/rust/pull/103514#issuecomment-1290833854) in a previous PR.
This commit is contained in:
commit
c89bb159f6
2 changed files with 13 additions and 0 deletions
|
@ -1499,6 +1499,11 @@ pub fn create_vtable_di_node<'ll, 'tcx>(
|
|||
return;
|
||||
}
|
||||
|
||||
// When full debuginfo is enabled, we want to try and prevent vtables from being
|
||||
// merged. Otherwise debuggers will have a hard time mapping from dyn pointer
|
||||
// to concrete type.
|
||||
llvm::SetUnnamedAddress(vtable, llvm::UnnamedAddr::No);
|
||||
|
||||
let vtable_name =
|
||||
compute_debuginfo_vtable_name(cx.tcx, ty, poly_trait_ref, VTableNameKind::GlobalVariable);
|
||||
let vtable_type_di_node = build_vtable_type_di_node(cx, ty, poly_trait_ref);
|
||||
|
|
|
@ -9,6 +9,14 @@
|
|||
// compile-flags: -Cdebuginfo=2 -Copt-level=0 -Csymbol-mangling-version=v0
|
||||
// ignore-tidy-linelength
|
||||
|
||||
// Make sure that vtables don't have the unnamed_addr attribute when debuginfo is enabled.
|
||||
// This helps debuggers more reliably map from dyn pointer to concrete type.
|
||||
// CHECK: @vtable.0 = private constant <{
|
||||
// CHECK: @vtable.1 = private constant <{
|
||||
// CHECK: @vtable.2 = private constant <{
|
||||
// CHECK: @vtable.3 = private constant <{
|
||||
// CHECK: @vtable.4 = private constant <{
|
||||
|
||||
// NONMSVC: ![[USIZE:[0-9]+]] = !DIBasicType(name: "usize"
|
||||
// MSVC: ![[USIZE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_typedef, name: "usize"
|
||||
// NONMSVC: ![[PTR:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "*const ()"
|
||||
|
|
Loading…
Add table
Reference in a new issue