Commit Graph

1105 Commits

Author SHA1 Message Date
Augusto Noronha
af1d477674 [DebugInfo] Emit a MultiPayloadEnum's spare bits mask in DWARF 2024-02-20 15:38:46 -08:00
Augusto Noronha
dc959a4eb4 Merge pull request #71332 from augusto2112/emit-class-deb
Generate full debug info for special builtins and classes
2024-02-06 17:08:33 -08:00
Kavon Farvardin
ee12fd6655 NCGenerics: reenable round-trip for mangling 2024-02-06 08:15:26 -08:00
Augusto Noronha
3352e7d157 [DebugInfo] Generate full debug info for classes 2024-02-05 16:44:44 -08:00
Augusto Noronha
2084da1163 Emit the special stdlib builtin types into full dwarf metadata 2024-02-02 18:15:31 -08:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Hamish Knight
fd97268393 Merge pull request #70983 from hamishknight/another-cleanup
[AST] Remove SerializedLocalDeclContext
2024-01-22 18:49:42 +00: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
Hamish Knight
3f4b45b012 [AST] Remove SerializedLocalDeclContext
It's not clear that its worth keeping this as a
base class for SerializedAbstractClosure and
SerializedTopLevelCodeDecl, most clients are
interested in the concrete kinds, not only whether
the context is serialized.
2024-01-18 12:03:52 +00:00
Doug Gregor
c31d45eda6 [Debug info] Map the thrown error type into context when generating debug info 2024-01-12 10:10:13 -08:00
Tony Allevato
49dbf152e0 Merge pull request #70371 from allevato/c++20-fixes
[C++20] Make `operator==` const.
2023-12-12 08:04:47 -05:00
Tony Allevato
c7e52ca7da [C++20] Make operator== const.
C++20 considers calls to `operator==` ambiguous with calls that have
the arguments reversed if the argument is const but `this` is not.
2023-12-11 09:14:29 -05:00
Doug Gregor
b080b5f3d8 [Typed throws] An ErrorUnion type to the type system
The errorUnion type operation specifies how thrown error types are
combined when multiple errors are thrown in the same context. When
thrown error types can have type variables in them, we sometimes cannot
resolve the errorUnion until the type variables have substitutions. In
such cases, we need to persist the result of errorUnion in the
constraint solver.

Introduce the ErrorUnionType to do exactly that, and update the core
errorUnion operation to produce an ErrorUnionType when needed. At
present, this code is inert, because any errorUnion operation today
involves only concrete types. However, inference of thrown errors in
closures will introduce type variables, and depend on this.
2023-12-08 22:30:37 -08:00
Kavon Farvardin
63b3e7624d [NCGenerics] fold InverseType into PCT
We already need to track the inverses separate from the members in a
ProtocolCompositionType, since inverses aren't real types. Thus, the
only purpose being served by InverseType is to be eliminated by
RequirementLowering when it appears in a conformance requirement.

Instead, we introduce separate type InverseRequirement just to keep
track of which inverses we encounter to facilitate cancelling-out
defaults and ensuring that the inverses are respected after running
the RequirementMachine.
2023-12-07 22:14:23 -08:00
Adrian Prantl
8626aeff03 [Debug Info] Store the source code for macro expansions in the debug info
This patch stores the source code of macro in the source field of DIFile, which
can be used together with the DW_LLVM_LNCT_source extension to emit the source
code into DWARF debug info.

rdar://110926109
2023-11-30 14:49:57 -08:00
Adrian Prantl
e4dd71bd87 [IRGenDebugInfo] Cache DIFile pointers instead of file names (NFC)
This is an NFC refactoring that is slightly more efficient and needed for
subsequent commits.
2023-11-29 12:37:06 -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
Doug Gregor
446dfbff3e Merge pull request #69741 from DougGregor/typed-throws-minor-fixes
Typed throws minor fixes
2023-11-09 10:17:58 -08:00
Doug Gregor
1a2f521aef [Debug info] Make sure we establish a generic scope for the thrown error type 2023-11-08 14:36:50 -08:00
Kuba Mracek
84561f9e69 [embedded] Avoid materializing generic functions for debuginfo purposes in embedded Swift 2023-11-06 15:37:57 -08:00
Kavon Farvardin
29acda5136 Merge pull request #69406 from kavon/noncopyable-generics-pt2
[NoncopyableGenerics] handle `~Copyable` in `where`, `some`, and compositions.
2023-10-28 22:36:22 -07:00
Adrian Prantl
5d978b44ca Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable."" 2023-10-26 12:29:18 -07:00
Adrian Prantl
2a32ca5944 Revert "Make the DWARF version emitted by the Swift compiler configurable." 2023-10-25 13:28:28 -07:00
Allan Shortlidge
d0a4f2633c NFC: Fix unused variable warnings. 2023-10-25 09:42:21 -07:00
Adrian Prantl
d19fe381fa Use LLVM definitions for Swift section names (NFC) 2023-10-24 10:58:40 -07:00
Kavon Farvardin
66712ce6e0 [Sema] introduce InverseType
This type will become the corresponding type that is resolved for an
`InverseTypeRepr`. This kind of type is not expected to appear past type
 checking (currently, not even past requirement lowering!).
2023-10-23 10:37:22 -07:00
Augusto Noronha
75e45bd024 Emit extra inhabitants in debug info for basic types
To support debugging embedded Swift, we will need to store information
that previously we searched in metadata. Extra inhabitants is one of
those.
2023-10-20 16:14:52 -07:00
swift-ci
042e9df19d Merge remote-tracking branch 'origin/main' into rebranch 2023-10-04 18:22:41 -07:00
Richard Howell
1bc715a8a1 Fix ASAN use-after-scope in module-file-home-is-cwd.swift 2023-10-04 12:11:48 -07:00
swift-ci
049f867392 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-03 13:58:47 -07:00
Richard Howell
76dd1f9069 Set clang module directory correctly with fmodule-file-home-is-cwd
When building and importing modules built with
`-fmodule-file-home-is-cwd` we should be setting the debug info
directory to the current working directory. This matches the
behavior in clang: https://reviews.llvm.org/D134911
2023-09-29 08:32:36 -07:00
swift-ci
af68664ed6 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-06 08:13:48 -07:00
Felipe de Azevedo Piovezan
2c3c3c1933 Merge pull request #67077 from DianQK/type-decl-disubprogram
[IRGen][DebugInfo] split method declaration and definition.
2023-09-06 11:08:39 -04:00
swift-ci
56b676b5e1 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 07:14:15 -07:00
Felipe de Azevedo Piovezan
af6599ff31 [IRGen] Delete no-op code
Commit 5c3ccf5050 added a number of blocks of code which were partially
removed by 39af79f491. This partial remove left lines of code doing nothin; we
remove them here.
2023-08-14 10:02:22 -04:00
DianQK
81953efcfb [IRGen][DebugInfo] Split method declaration and definition.
When the function is a method, we want a DW_AT_declaration there.
Because there's no good way to cross the CU boundary to insert a nested
DISubprogram definition in one CU into a type defined in another CU when
doing LTO builds.
2023-08-06 20:21:15 +08:00
swift-ci
6da5bed7fb Merge remote-tracking branch 'origin/main' into rebranch 2023-08-05 18:36:02 -07:00
Tony Allevato
300a952ede Replace u8 string literal prefixes with SWIFT_UTF8 macro.
In C++20, `u8` literals create values of type `char8_t` instead of
`char`, and these can't be implicitly converted. This macro
mitigates the difference and allows the same code to compile under
C++14/17 modes and C++20, preserving the `char` type while ensuring
that the text is interpreted as UTF-8.
2023-08-04 16:41:36 -04:00
swift-ci
6610561794 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-28 08:53:26 -07:00
Adrian Prantl
1f6091aa45 Merge pull request #66744 from asavonic/debuginfo-fragment-distinct-inline-loc
[DebugInfo] Emit distinct DILocation for different inline instances
2023-07-28 08:45:53 -07:00
Evan Wilde
ecbccb9310 Update clang TargetInfo AddressSpace API usage
The TargetInfo pointer APIs updated to taking an "AddressSpace" type
instead of a raw integer. This goes through and updates the call
locations where this change caused build failures. In all cases, the
value passed was `0`, corresponding with the Default AddressSpace.
2023-07-25 12:28:28 -07:00
Evan Wilde
f4946e9718 Updating more alignment APIs
Adding a few more updates to places where the ABI Alignment functions
changed. `getABITypeAlignment` was replaced with `getABITypeAlign`,
which returns an `llvm::Align` instead of an unsigned int.
2023-07-25 12:28:28 -07:00
swift_jenkins
2ff66f1c25 Merge remote-tracking branch 'origin/main' into next 2023-07-07 08:05:35 -07:00
Hiroshi Yamauchi
fda6f9b62f Fix a round trip debug type failure with typealias
When checking equality of types with existential types removed,
recursively remove existential types inside an existential type.

Fixes: #66554
2023-06-30 14:04:28 -07:00
Evan Wilde
7c77fa6f45 Merge branch 'main' into ewilde/update-next
Automerger into next doesn't seem to be working. Manually merging.
2023-06-29 08:33:53 -07:00
Andrew Savonichev
ca6e74226d [DebugInfo] Emit distinct DILocation for different inline instances
LLVM seems to determine a variable instance as a combination of DILocalVariable
and DILocation. Therefore if multiple llvm.dbg.declare have the same
variable/location parameters, they are considered to be referencing the same
instance of variable.

Swift IRGen emits a set of llvm.dbg.declare calls for every variable
instance (with unique SILDebugScope), so it is important that these calls have
distinct variable/location parameters. Otherwise their DIExpression may be
incorrect when treated as referencing the same variable. For example, if they
have a DIExpression with fragments, we will see this as multiple declarations of
the same fragment. LLVM detects this and crashes with assertion failure:

DwarfExpression.cpp:679: void llvm::DwarfExpression::addFragmentOffset(const
llvm::DIExpression *): Assertion `FragmentOffset >= OffsetInBits &&
"overlapping or duplicate fragments"' failed.

The patch resolves #55703. The LIT test (debug_scope_distinct.swift) is the
reproducer from that issue.
2023-06-29 17:06:24 +09:00
Erik Eckstein
6b1697eb06 use new llvm::Optional APIs to fix deprecation warnings 2023-06-28 14:28:38 +02:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Felipe de Azevedo Piovezan
73f39af392 Merge remote-tracking branch 'origin/main' into felipe/fix_merge_opaque
The following tests required conflict resolutions, since upstream LLVM did a lot of
work to remove dbg.addr, and this work is not available to swift's main. At the
same time, swift's main changed these tests to enable opaque pointers.

```
both modified:   test/DebugInfo/async-let-await.swift
both modified:   test/DebugInfo/move_function_dbginfo.swift
both modified:   test/DebugInfo/move_function_dbginfo_async.swift
```

The conflicts are fairly easy to fix: we keep the "structure" of the CHECK
lines present in `next`, but replace all pointers with `ptr`.
2023-06-26 17:13:02 -04:00