-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[debuginfo] Make cpp-like debuginfo type names for slices and str consistent. #103691
[debuginfo] Make cpp-like debuginfo type names for slices and str consistent. #103691
Conversation
84986c2
to
f285bc9
Compare
This comment has been minimized.
This comment has been minimized.
Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type. This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect.
f285bc9
to
0cd2dd7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @michaelwoerister!
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b0f3940): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
…d-str-cpp-like-debuginfo-names, r=wesleywiser [debuginfo] Make cpp-like debuginfo type names for slices and str consistent. Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type. This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect. The new special name for slices is `slice2$` to differentiate it from the previous name `slice$`, which has different semantics. The same is true for `str` and `str$`. This kind of versioning already has a precedent with the case of `enum$` and `enum2$` and hopefully will make it easier to transition existing consumers of these names. cc `@rust-lang/wg-debugging` `@vadimcn` r? `@wesleywiser` UPDATE: Here is a table to clarify the changes | Rust type | DWARF name | C++-like name (before) | C++-like name (after) | |-----------|------------|------------------------|------------------------| | `[T]` | `[T]` | `slice$<T>` | `slice2$<T>` | | `&[T]` | `&[T]` | `slice$<T>` | `ref$<slice2$<T> >` | | `&mut [T]` | `&mut [T]` | `slice$<T>` | `ref_mut$<slice2$<T> >`| | `str` | `str` | `str` | `str$` | | `&str` | `&str` | `str` | `ref$<str$>` | | `&mut str` | `&mut str` | `str` | `ref_mut$<str$>`| | `*const [T]` | `*const [T]` | `ptr_const$<slice$<T> >` | `ptr_const$<slice2$<T> >` | | `*mut [T]` | `*mut [T]` | `ptr_mut$<slice$<T> >` | `ptr_mut$<slice2$<T> >` | As you can see, before the PR many types would end up with the same name, making it impossible to distinguish between them in NatVis or other places where types are matched or looked up by name. The DWARF version of names is not changed.
Before this PR, the compiler would emit the debuginfo name
slice$<T>
for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the typesFoo<&[T]>
,Foo<[T]>
, andFoo<&mut [T]>
would end up with the same type nameFoo<slice$<T> >
in debuginfo, making it impossible to disambiguate between them by name. Similarly,&str
would get the namestr
in debuginfo, so the debuginfo name forFoo<str>
andFoo<&str>
would be the same. In contrast,*const [bool]
and*mut [bool]
would beptr_const$<slice$<bool> >
andptr_mut$<slice$<bool> >
, i.e. the encoding does not lose information about the type.This PR removes all special handling for slices and
str
. The types&[bool]
,&mut [bool]
, and&str
thus get the namesref$<slice2$<bool> >
,ref_mut$<slice2$<bool> >
, andref$<str$>
respectively -- as one would expect.The new special name for slices is
slice2$
to differentiate it from the previous nameslice$
, which has different semantics. The same is true forstr
andstr$
. This kind of versioning already has a precedent with the case ofenum$
andenum2$
and hopefully will make it easier to transition existing consumers of these names.cc @rust-lang/wg-debugging @vadimcn
r? @wesleywiser
UPDATE: Here is a table to clarify the changes
[T]
[T]
slice$<T>
slice2$<T>
&[T]
&[T]
slice$<T>
ref$<slice2$<T> >
&mut [T]
&mut [T]
slice$<T>
ref_mut$<slice2$<T> >
str
str
str
str$
&str
&str
str
ref$<str$>
&mut str
&mut str
str
ref_mut$<str$>
*const [T]
*const [T]
ptr_const$<slice$<T> >
ptr_const$<slice2$<T> >
*mut [T]
*mut [T]
ptr_mut$<slice$<T> >
ptr_mut$<slice2$<T> >
As you can see, before the PR many types would end up with the same name, making it impossible to distinguish between them in NatVis or other places where types are matched or looked up by name. The DWARF version of names is not changed.