Skip to content

Commit 5144661

Browse files
Remove out-dated information from rustc_codegen_llvm/src/debuginfo/doc.md
1 parent abe854f commit 5144661

File tree

1 file changed

+5
-54
lines changed
  • compiler/rustc_codegen_llvm/src/debuginfo

1 file changed

+5
-54
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/doc.md

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The function will take care of probing the cache for an existing node for
3434
that exact file path.
3535

3636
All private state used by the module is stored within either the
37-
CrateDebugContext struct (owned by the CodegenCx) or the
37+
CodegenUnitDebugContext struct (owned by the CodegenCx) or the
3838
FunctionDebugContext (owned by the FunctionCx).
3939

4040
This file consists of three conceptual sections:
@@ -72,21 +72,16 @@ describe(t = List)
7272
...
7373
```
7474

75-
To break cycles like these, we use "forward declarations". That is, when
75+
To break cycles like these, we use "stubs". That is, when
7676
the algorithm encounters a possibly recursive type (any struct or enum), it
7777
immediately creates a type description node and inserts it into the cache
7878
*before* describing the members of the type. This type description is just
7979
a stub (as type members are not described and added to it yet) but it
8080
allows the algorithm to already refer to the type. After the stub is
8181
inserted into the cache, the algorithm continues as before. If it now
8282
encounters a recursive reference, it will hit the cache and does not try to
83-
describe the type anew.
84-
85-
This behavior is encapsulated in the 'RecursiveTypeDescription' enum,
86-
which represents a kind of continuation, storing all state needed to
87-
continue traversal at the type members after the type has been registered
88-
with the cache. (This implementation approach might be a tad over-
89-
engineered and may change in the future)
83+
describe the type anew. This behavior is encapsulated in the
84+
`type_map::build_type_with_children()` function.
9085

9186

9287
## Source Locations and Line Information
@@ -133,48 +128,4 @@ in the middle of the prologue, however, they are ignored by LLVM's prologue
133128
detection. The `create_argument_metadata()` and related functions take care
134129
of linking the `llvm.dbg.declare` instructions to the correct source
135130
locations even while source location emission is still disabled, so there
136-
is no need to do anything special with source location handling here.
137-
138-
## Unique Type Identification
139-
140-
In order for link-time optimization to work properly, LLVM needs a unique
141-
type identifier that tells it across compilation units which types are the
142-
same as others. This type identifier is created by
143-
`TypeMap::get_unique_type_id_of_type()` using the following algorithm:
144-
145-
1. Primitive types have their name as ID
146-
147-
2. Structs, enums and traits have a multipart identifier
148-
149-
1. The first part is the SVH (strict version hash) of the crate they
150-
were originally defined in
151-
152-
2. The second part is the ast::NodeId of the definition in their
153-
original crate
154-
155-
3. The final part is a concatenation of the type IDs of their concrete
156-
type arguments if they are generic types.
157-
158-
3. Tuple-, pointer-, and function types are structurally identified, which
159-
means that they are equivalent if their component types are equivalent
160-
(i.e., `(i32, i32)` is the same regardless in which crate it is used).
161-
162-
This algorithm also provides a stable ID for types that are defined in one
163-
crate but instantiated from metadata within another crate. We just have to
164-
take care to always map crate and `NodeId`s back to the original crate
165-
context.
166-
167-
As a side-effect these unique type IDs also help to solve a problem arising
168-
from lifetime parameters. Since lifetime parameters are completely omitted
169-
in debuginfo, more than one `Ty` instance may map to the same debuginfo
170-
type metadata, that is, some struct `Struct<'a>` may have N instantiations
171-
with different concrete substitutions for `'a`, and thus there will be N
172-
`Ty` instances for the type `Struct<'a>` even though it is not generic
173-
otherwise. Unfortunately this means that we cannot use `ty::type_id()` as
174-
cheap identifier for type metadata -- we have done this in the past, but it
175-
led to unnecessary metadata duplication in the best case and LLVM
176-
assertions in the worst. However, the unique type ID as described above
177-
*can* be used as identifier. Since it is comparatively expensive to
178-
construct, though, `ty::type_id()` is still used additionally as an
179-
optimization for cases where the exact same type has been seen before
180-
(which is most of the time).
131+
is no need to do anything special with source location handling here.

0 commit comments

Comments
 (0)