Commit Graph

51 Commits

Author SHA1 Message Date
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
Augusto Noronha
459c7fdc7b [DebugInfo] Stop emitting spare bits mask in debug info
We're now able to calculate the spare bits mask from other information.
Stop emitting it in debug info.
2024-11-01 15:51:59 -07:00
Augusto Noronha
393849290b [DebugInfo] Emit full DWARF info for generic classes and enums 2024-02-20 20:03:14 -08:00
Augusto Noronha
af1d477674 [DebugInfo] Emit a MultiPayloadEnum's spare bits mask in DWARF 2024-02-20 15:38:46 -08:00
Augusto Noronha
46117cefdd [NFC] Fix debug info enum test failing on 32 bit 2023-11-30 11:35:01 -08:00
Augusto Noronha
594f51a13e Generate full debug info for enums
Replace the generation of debug info for enums from DW_TAG_union_type
to either DW_TAG_enumeration_type or DW_TAG_variant_part, as these
representation match Swift enums more closely.
2023-11-13 14:31:29 -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
57b1664f92 Debug Info: Distinguish between types of unknown size and types with size=0.
DebugInfoTypes didn't properly distinguish between types with an unknown size
and used 0 as the default value. This can cause types to show up in DWARF with a
size of 0, which will prevent LLDB from looking at the type further. In
practice, this meant that many resilient types (for example, SwiftUI Views)
couldn't be displayed in the debugger and just showed up as empty.

This patch does three things:

0. Make size in DebugTypeInfo optional.
1. Introduce CompletedDebugTypeInfo, a subclass of DebugTypeInfo where
   size is guaranteed to be non-empty.
2. Change some APIs that only make sense with a size to use
   CompletedDebugTypeInfo. This caused some churn because I needed to refactor
	 the get*Elements() functions back into their callers to facilitate the new
	 early-exit path. These functions are only called when compiling with
	 -gdwarf-types.
3. Change createOpaqueStructWithSizedContainer() to create a size-less forward
   declaration instead of a zero-sized type for the inner type.

rdar://76973844
(cherry picked from commit b8e6eebdbc)
2021-05-20 13:48:47 -07:00
Adrian Prantl
248ba6236a Don't emit debug line numbers for Swift type forward declarations
These line numbers are consumed by LLDB and stored in the Declaration object,
but as far as I can tell no user-facing feature relies on this.

Removing the line number can reduce the churn for incremental builds
significantly, since whitespace changes in one file may trigger a recompilation
of any file that uses a type declared below the whitespace change.

<rdar://problem/63156560>
2020-05-13 16:57:44 -07: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
Adrian Prantl
e881168d5e Debug Info: Avoid type uniquing clashes for bound generic enums.
This patch changes the DWARF representation of bound generic enums to a nested
struct where the (sized) outer struct is anonymous and thus distinct and the
inner struct in uniqued and sizeless.

BoundGenericEnums may have different sizes depending on what they are bound to,
but still share a mangled name.

rdar://problem/56521648
2019-11-04 08:22:00 -08:00
Adrian Prantl
ff22da20c3 Debug Info: Encode let-bindings using DW_TAG_const_type.
This allows the debugger to distinguish constant "let" values from
mutable "var" variables.

rdar://problem/16042546
2019-09-25 08:51:05 -07:00
Davide Italiano
854dffb200 [DebugInfo] Stop handling InOut types, they'll be gone soon.
<rdar://problem/46043909>
2018-12-06 13:38:34 -08:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Adrian Prantl
bab3000069 Use depth and index to lookup type metadata artificial variables
instead of using name and decl context.

The advantages of this approach are three-fold:
- This is necessary to support inlined generic functions.
- We can retire the debugger-specific type name manfgling mode for archetypes.
- This saves 270kb of debug information in the x86_64 libSwiftCore.dylib alone.

<rdar://problem/38306256>
2018-06-12 12:48:15 -07:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
600b15821d [Mangling/ABI] NFC: Fix DebugInfo tests to reflect label mangling changes 2017-12-18 15:44:24 -08:00
Adrian Prantl
f7742121a5 Debug Info: Record the base name for inout types and fix tests for i386.
rdar://problem/33761763
2017-08-09 15:22:13 -07:00
Joe Shajrawi
84994dc786 Enable large loadable types by default 2017-08-03 11:45:28 -07:00
Adrian Prantl
8e6d6338ce Emit debug info for Swift types using the default alignment where possible.
This patch emits the alignment for all default-aligned types as 0
which causes the backend to not emit an alignment attribute at
all. This mirrors clang's behavior.

<rdar://problem/29007471>
2017-04-17 11:35:33 -07:00
Erik Eckstein
2a55b26e46 Mangling: enable new mangling for symbols 2017-03-16 12:04:08 -07:00
Adrian Prantl
0e9c8e9db4 Update for LLVM API change D20147. 2016-09-20 18:14:03 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Adrian Prantl
361beff9c0 Emit pointer-sized structs only when -gdwarf-types is specified.
rdar://problem/25498103
2016-07-05 17:03:10 -07:00
Adrian Prantl
0847225962 Only emit DWARF types for enums when -gdwarf-types is specified. 2016-07-05 16:00:09 -07:00
Adrian Prantl
33ac7eb351 Only emit DWARF types for tuple types under -gdwarf-types. 2016-07-05 15:18:05 -07:00
Adrian Prantl
e2f05f046b Only emit DWARF types for function pointers when -gdwarf-types is specified. 2016-07-05 15:16:42 -07:00
Adrian Prantl
0fac43e11f Adapt to upstream LLVM changes.
<rdar://problem/25949511+25962000>

(cherry picked from commit df9dfac609d17cd26d6107f17024c937b1b5b1a2)
2016-05-13 22:04:00 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Adrian Prantl
d6e3a0f8a2 Fix testcase for 32-bit platforms. 2016-03-18 17:48:30 -07:00
Adrian Prantl
e1749d245e Don't emit debug info for value witness tables.
Value witness tables have a well-known symbol name, so there is nothing
that the debug info adds on top of it.

On top of that, the DWARF type we previously were emitting them with was
bogus.

rdar://problem/21777112
2016-03-18 16:58:43 -07:00
Adrian Prantl
5726370c1a Debug Info: Improve the accuracy of enum elements' sizes within the
limitations of LLVM.
2016-03-10 10:13:51 -08:00
Dmitri Gribenko
65d840c0ae stdlib: lowercase cases in Optional and ImplicitlyUnwrappedOptional 2016-02-18 00:40:33 -08:00
Adrian Prantl
9b0d2cc8d6 Force generic enums to be instantiated in this testcase and unXFAIL it. 2015-12-10 17:11:53 -08:00
Slava Pestov
0a072484ec SILGen: Emit enum case constructors lazily
Now that we open-code enum construction, enum constructor entry points are
only needed when they are partially-applied, which is a rare case. So we
treat them like curry thunks and only emit them as needed.

The main consequence of this is that enum case constructors are no longer
part of our ABI.

To avoid a regression in the code path for diagnosing infinite value types,
force type lowering to walk a type when emitting its declaration, even if
there are no other references to the type in the program (which is now the
case for public enums which are otherwise not used).

Also XFAIL a DebugInfo test since it is not clear to me what the test does
or how to fix it. The obvious change of adding references to the enum
case constructor function to force it to be emitted did not work.
2015-12-10 16:39:48 -08:00
Joe Groff
2368ce774b Remove self types from mangling by default.
And include some supplementary mangling changes:

- Give the first generic param (depth=0, index=0) a single character mangling. Even after removing the self type from method declaration types, 'Self' still shows up very frequently in protocol requirement signatures.
- Fix the mangling of generic parameter counts to elide the count when there's only one parameter at the starting depth of the mangling.

Together these carve another 154KB out of a debug standard library. There's some awkwardness in demangled strings that I'll clean up in subsequent commits; since decl types now only mangle the number of generic params at their own depth, it's context-dependent what depths those represent, which we get wrong now. Currying markers are also wrong, but since free function currying is going away, we can mangle the partial application thunks in different ways.

Swift SVN r32896
2015-10-26 22:05:20 +00:00
Joe Groff
0cd5aa8c7c Change mangling for the Swift module from 'Ss' to 's'.
'Ss' appears in manglings tens of thousands of times in the standard library and is also incredibly frequent in other modules. This alone is enough to shrink the standard library by 59KB.

Swift SVN r32409
2015-10-02 22:39:44 +00:00
Michael Gottesman
6d74962918 Adapt all DebugInfo testcases to the new upstream LLVM metadata format.
Swift SVN r31813
2015-09-09 04:37:34 +00:00
Adrian Prantl
4f11ecc1da Get rid of Int in the debug info tests and preform some general cleanup.
<rdar://problem/20856296> Extinguish 'Int' from DebugInfo tests

Swift SVN r31177
2015-08-12 18:16:43 +00:00
Frederic Riss
f3816e6dfa DebugInfo: Do not infinite loop on indirect enums.
When computing the locations for local indirect enums, we could enter
an infinite loop if the first field is a recursive reference.
Just bail out of the field-splitting logic if we encounter an indirect
case. More work might be needed if indirect enums get exploded.

rdar://problem/21927941

Swift SVN r30717
2015-07-28 17:18:02 +00:00
Adrian Prantl
e91b59ff79 Debug Info: Also treat tuple types like all other composite types and
create a replaceable forward declaration while building it.
This fixes a crash when building generic enums a tuple element recursively
referenceing the enum.

rdar://problem/21326786

Swift SVN r29416
2015-06-17 00:36:05 +00:00
Adrian Prantl
44f78857f3 Debug Info: Treat subroutine types like all other composite types
and create a replaceable forward declaration while building it.
This fixes a crash when building generic enums with a constructor
function.

<rdar://problem/21294835>

Swift SVN r29411
2015-06-16 23:29:26 +00:00
Duncan Exon Smith
c6d42db070 Adapt to MD* => DI* renaming of debug info types
Applied the upgrade script from r236120 (LLVM) and r236121 (CFE).  This is the
final step of rdar://problem/20434113.



Swift SVN r27925
2015-04-29 21:40:21 +00:00
Adrian Prantl
56e8ae7d82 Add missing testcase for r27562.
Swift SVN r27579
2015-04-22 15:57:37 +00:00
Adrian Prantl
3c6af3610a Debug Info: type-unique enum types by virtue of their mangled name.
rdar://problem/20015686

Swift SVN r26104
2015-03-13 18:13:59 +00:00
Duncan Exon Smith
093eb3c365 DebugInfo: Hand-update testcases after LLVM r231082
Update debug info testcases after moving the new hierarchy into place in
upstream LLVM r231082.

rdar://problem/19720042



Swift SVN r25715
2015-03-03 19:15:31 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Ted Kremenek
d075f06573 Require a minimum deployment target of iOS 7 or OSX 10.9
Implements <rdar://problem/17532113>

Swift SVN r19451
2014-07-02 06:23:38 +00:00