Commit Graph

14 Commits

Author SHA1 Message Date
Adrian Prantl
851470f476 [Debug Info] Do not emit children of bound generic types
This reverts the problematic parts of
fcbebc51c7 which had caused a lot of
unintended fallout, while preserving the actual feature supported by
the patch.

Before that patch (fcbeb), and after this one, we don't emit members
of specialized bound generic types, because these can be reconstructed
by substituting the "template parameters" in the unspecialized
type. This patch carves out an exception for inline arrays, because
DWARF has special support for arrays, which allows debuggers to reason
about them without needing special support.

rdar://146326633
2025-03-18 17:07:08 -07:00
Adrian Prantl
34cda58239 [Debug Info] Prevent infinite recursion when emitting debug info
for recursive classes. This is achieved by treating types created with
DebugTypeInfo::createFrowardDecl() as unconditional forward
declarations when emitting debug info instead of applying a heuristic
to determine this.

rdar://146688269
2025-03-12 11:07:26 -07:00
Adrian Prantl
fcbebc51c7 [Debug Info] Emit -gdwarf-types debug info for Builtin.FixedArray<>
This commit also changes how specialized types are being emitted. Previously we
would not emitthe detailed member information in the specialized type itself,
and instead rely on the fact that it was present in the unspecialized type,
however, this wold prevent us from emitting any bound generic members, so we're
now emitting the members in both variants of the type.

This uncovered a with type aliases that this commit also addresses: Because we
don't canonicalize types prior to caching in order to preserve type sugar,
alternative representations of recursive types (with one or more levels of
recursion unfolded) could create potential infinite chains of types. This is
addressed by checking whether a sugared type has an already emitted canonical
representation first, and if yes, creating a typedef node pointing directly to
it.

The donwside of doing this is that it can lead to the disappearnce of type
aliases definitions when they are used as parameters in bound generic
types. However, we still preserve that a type was `MyClass<MyAlias>`. We just
might have a typedef pointing director from `MyClass<MyAlias>` ->
`MyClass<CanonicalType>`.

rdar://144315592
2025-02-14 12:19:58 -08:00
Adrian Prantl
91b6162f25 [Debug info] Emit bound generic class type parameters when emitting AST types
This relands commit 45d4648bdb while ensuring that
sanityCheckCachedType uses the exact same condition (now factored into a helper
function) as createType() to determine whether a type is sized or not.

rdar://143833326
2025-02-01 10:07:45 -08:00
Adrian Prantl
45d4648bdb Revert "[Debug info] Emit bound generic class type parameters when emitting AST types"
This reverts commit f2132890db
it triggers the debug info sanity check when running the source compatibility testsuite.
2025-01-30 17:27:39 -08:00
Adrian Prantl
f2132890db [Debug info] Emit bound generic class type parameters when emitting AST types
This ensures that debug info for these types is emitted even if this is the only
way they are references in the input program.

rdar://143595521
2025-01-28 17:39:18 -08:00
Adrian Prantl
e70a3443e9 [Debug Info] Remove the mostly unused FragmentType from DebugTypeInfo
This cleanup allows for more consistent debug info emission since we depend less
on IRGen magic to emit debug info for types.
2025-01-27 17:28:10 -08:00
Augusto Noronha
f679a68e5d [DebugInfo] Fix tests to downstream "specification" attribute
The "specification_of" attribute in LLVM IR was renamed to
"specification". Adapt the  tests to the new name.
2024-11-14 13:17:58 -08:00
Augusto Noronha
ae5e341db4 [DebugInfo] Generate debug info for specialized types
Specialized types are generic types, or types whose parent is
specialized.

IRGenDebugInfo was previously mistankenly emitting debug info for
nominal specialized types as if they regular nominal types, which caused
problems as that code path does not handle references to generic
parameters.
2024-03-18 15:43:38 -07:00
Augusto Noronha
10d263b388 [DebugInfo] Fix bound generic types debug info generation
When generating full debug info for generic types, emit the
specification type as an opaque struct with the collection of
substituted generic parameters.
2024-02-27 17:49:27 -08:00
Augusto Noronha
393849290b [DebugInfo] Emit full DWARF info for generic classes and enums 2024-02-20 20:03:14 -08:00
Augusto Noronha
1bf6375b78 [DebugInfo] Generate full debug info for generic structs
Generate the full debug info for generic structs. The strategy is to
emit one full entry for the generic type with archetypes, and one
forward declaration per instantiation of the generic type.

For example, given:
```
struct Pair<T, U> {
  let t: T
  let u: U
}
let p1 = Pair<Int, Double>(t: 1, u: 4.2)
let p2 = Pair<String, Bool>(t: "Hello", u: true)
```

DebugInfo will have one entry for Pair<T, U> which includes descriptions
of its fields, one forward declaration of Pair<Int, Double> and one
forward declaration of Pair<String, Bool>. This information is enough
for the algorithms of RemoteMirrors to reconstruct type information for
the fully instantiated types.
2024-01-19 12:35:30 -08:00
Adrian Prantl
0f4429b224 DebugTypeInfo: Prefer the size of the Storage type derived from the TypeInfo.
Previously type sizes would be inconsistently sourced from either the LLVM type
or the FixedTypeInfo, depending on the call site. This was problematic because
TypeInfo operates with a resolution of whole bytes, which means that types such
as i1 would get a reported as having a size of 8. This patch now asserts that
all occurrences of the same type have the same size as the first, cached
occurence.

To avoid triggering the cached type verification assertion, this patch avoids
caching of storage-sized containers. It also removes the unique identifier from
forward declarations, which could lead to type confusion during LTO.

rdar://102367872
2023-02-08 15:09:53 -08:00
Adrian Prantl
3bc9d43d12 Store the type parameters of bound generics in the debug info.
This is needed to anchor any typedefs that appear in bound generic parameters so
they can be resolved in the typeref-based part of the debugger without needing
to query the Swift module.
2020-04-20 14:45:58 -07:00