Commit Graph

1161 Commits

Author SHA1 Message Date
swift-ci
0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Meghana Gupta
9fe489ce22 Introduce borrow and mutate as new accessor kinds
And handle them in various covered switches
2025-09-09 14:30:26 -07:00
Shubham Sandeep Rastogi
3eb40fc19c Emit llvm.dbg.coroframe_entry instead of llvm.dbg.declare for async code.
For swift async debug info, we create llvm.dbg.declare that contain
locations which may not be a pointer or int. This is fine, because the
CoroSplitter pass fixes up those llvm.dbg.declares later.

However, with a recent change to the LLVM Verifier, there is a check
that asserts if there is a llvm.dbg.declare with a location other than
a pointer or an int.

To workaround the problem, we created a new llvm.dbg.coroframe_entry
intrinsic that doesn't have the same restriction as llvm.dbg.declare.

This patch ensures that in async code, we now emit the new
llvm.dbg.coroframe_entry intrinsic, instead of llvm.dbg.declare
intrinsic

rdar://157299589

rdar://157509307
2025-08-23 20:13:18 -07:00
Shubham Sandeep Rastogi
35ed2080ba Revert "Temporarily disable debug info generation for async functions"
This reverts commit 8d763321c1.
2025-08-22 15:31:47 -07:00
Ben Barham
8d763321c1 Temporarily disable debug info generation for async functions
Temporary workaround for a compiler crash in rebranch:
```
location of #dbg_declare must be a pointer or int
```
2025-08-13 15:36:02 -07:00
Anthony Latsis
1de3e14252 Revert "DebugInfo: Bring back accidentally dropped DIFlagArtificial flag"
This reverts commit 5a456c5c3f.
2025-07-31 11:43:26 +01:00
Anthony Latsis
5a456c5c3f DebugInfo: Bring back accidentally dropped DIFlagArtificial flag
Patches up https://github.com/swiftlang/swift/pull/83283.
2025-07-30 23:28:53 +01:00
swift-ci
3998a187f9 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-30 09:36:41 -07:00
Anthony Latsis
3f841b515c Merge remote-tracking branch 'origin/main' into jepa-rebranch 2025-07-30 14:31:33 +01:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Shubham Sandeep Rastogi
5b4fdd6e62 Revert "Set the Compilation directory when generating the Skeleton CU"
This reverts commit b286b1c3a5.

Reverted because fix for rdar://131726681 broke rdar://154247270

Reverting and will try to fix properly later
2025-07-24 10:59:11 -07:00
Anthony Latsis
7f8dc07f1c Merge pull request #83283 from swiftlang/jepa-rebranch
DebugInfo: Stop setting `FlagObjectPointer` without being certain tha…
2025-07-24 09:56:59 +01:00
Anthony Latsis
e246f0de59 DebugInfo: Stop setting FlagObjectPointer without being certain that the parameter is self
The stable/21.x branch is not happy with us setting the object pointer
flag here because it now asserts that this flag is set for at most one
function parameter. We should add a dedicated routine for instance
method parameters. For now, stop setting the flag altogether to unblock
the stdlib build on rebranch.
2025-07-24 09:17:00 +01:00
swift-ci
077ba17bee Merge remote-tracking branch 'origin/main' into rebranch 2025-07-23 23:18:26 -07:00
Augusto Noronha
c03831f70d [DebugInfo] Fix infinite recursion when opaque return type is defined
inside function returning it

A stack overflow would happen when the compiler tried emitting debug
info for a function whose opaque return type was declared inside the
function itself. This fixes the issue by emitting a forward declaration
for the function before emitting it.

rdar://150313956
2025-07-23 15:24:34 -07:00
Anthony Latsis
b04d6085f3 IRGen: Address llvm::InsertPosition ctor deprecation
See https://github.com/llvm/llvm-project/pull/102608.
2025-07-21 12:50:39 +01:00
swift-ci
3787a312d7 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-15 17:17:19 -07:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
swift-ci
7373597cc8 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-30 15:54:31 -07:00
Augusto Noronha
0c20222aea Merge pull request #81700 from augusto2112/revert-debug-info-witness-table
Revert "Merge pull request #79171 from augusto2112/debug-info-witness…
2025-06-30 15:28:15 -07:00
swift-ci
457aa96d07 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-23 14:54:46 -07:00
Shubham Sandeep Rastogi
f91f8c5283 Merge pull request #81563 from rastogishubham/CompDir
Set the Compilation directory when generating the Skeleton CU
2025-05-23 14:39:16 -07:00
Shubham Sandeep Rastogi
b286b1c3a5 Set the Compilation directory when generating the Skeleton CU
When creating a skeleton Compile Unit, the DIFile passed
in, it always uses the include path. This leads to the DW_AT_comp_dir
being wrong, if the -file-compilation-dir option is passed, we need to
use the remapped compilation dir passed in to the DIFile instead.

This patch fixes that problem.
2025-05-22 08:37:10 -07:00
Augusto Noronha
680fbc566f Revert "Merge pull request #79171 from augusto2112/debug-info-witness-table"
This reverts commit c8eba86c3e, reversing
changes made to 98c3993503.
2025-05-22 11:45:37 +09:00
Anthony Latsis
12823706a8 Merge pull request #81667 from AnthonyLatsis/rebranch
[rebranch] DebugInfo: Restore old behavior in call to `llvm::DIBuilder::createOb…
2025-05-21 05:48:46 +01:00
Anthony Latsis
ff64fc79af DebugInfo: Restore old behavior in call to llvm::DIBuilder::createObjectPointerType
Fix my mistake in 66a6df9a44. `false` is
the wrong value for the new `Implicit` parameter because it causes the
`FlagArtificial` flag to not be set as before that change. The flag
itself looks appropriate because the entry is constructed for a built-in
type.
2025-05-21 05:44:06 +01:00
swift-ci
8108f779a5 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-20 17:48:45 -07:00
Augusto Noronha
c8eba86c3e Merge pull request #79171 from augusto2112/debug-info-witness-table
[DebugInfo] Emit debug info for witness tables
2025-05-21 09:23:04 +09:00
swift-ci
fe523c4b0b Merge remote-tracking branch 'origin/main' into rebranch 2025-05-20 02:15:11 -07:00
Hamish Knight
edca7c85ad Adopt ABORT throughout the compiler
Convert a bunch of places where we're dumping to stderr and calling
`abort` over to using `ABORT` such that the message gets printed to
the pretty stack trace. This ensures it gets picked up by
CrashReporter.
2025-05-19 20:55:01 +01:00
Augusto Noronha
66748f71eb [DebugInfo] Emit debug info for witness tables
This change emits debug info for witness tables passed into generic
functions when a generic type is constrained to a protocol. This
information is required for LLDB's generic expression evaluator
to work in such functions.

rdar://104446865
2025-04-30 11:18:19 -07:00
Anthony Latsis
e124bca3e1 IRGen: Adjust uses of llvm::DIBuilder::insertDbgValueIntrinsic (parameter type changed)
Per 1083ec647f16314bcc9af8c4d6b11f50d288bca6 (llvm-project).
2025-04-24 01:52:48 +01:00
Anthony Latsis
4e972c0e75 IRGen: Adjust uses of llvm::BasicBlock::getFirstNonPHIOrDbg (return type changed)
Per 81d18ad86419fc612c7071e888d11aa923eaeb8a (llvm-project).
2025-04-24 01:52:48 +01:00
Anthony Latsis
66a6df9a44 IRGen: Conservatively adjust use of llvm::DIBuilder::createObjectPointerType (parameter added)
Per a5fb2bbb2ad8488482843e2298fbe6f6a1d45bbd (llvm-project).
2025-04-24 01:52:48 +01:00
John Hui
dd2f465025 [cxx-interop] Do not get private discriminator for private Clang types (#80485)
When generating debug symbols for private Clang types (which we started
importing recently), the compiler crashes due to an assertion failure
from ClangModuleUnit::getDiscriminatorForPrivateDecl(), which is called
by getFilePrivateScope().

This patch fixes the issue crash by not calling getFilePrivateScope()
for Clang types. A discriminator is usually needed to disambiguate
private Swift types declared in different files, but Clang types follow
different scoping conventions that make this discriminator unnecessary.

rdar://148481025
2025-04-09 22:32:12 -07:00
Slava Pestov
0155b41b50 AST: Extend @_originallyDefinedIn to allow specifying module name for linker directive purposes
The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.

If there is no semicolon, both module names are identical,
and the behavior is the same as before.
2025-03-24 17:56:45 -04:00
Pavel Yaskevich
a59a2a1690 Merge pull request #80229 from swiftlang/remove-dumps
Remove extraneous `dump`
2025-03-23 22:16:14 -07:00
Hamish Knight
f8ab391737 Introduce type sugar for InlineArray (#80087)
* [CS] Decline to handle InlineArray in shrink

Previously we would try the contextual type `(<int>, <element>)`,
which is wrong. Given we want to eliminate shrink, let's just bail.

* [Sema] Sink `ValueMatchVisitor` into `applyUnboundGenericArguments`

Make sure it's called for sugar code paths too. Also let's just always
run it since it should be a pretty cheap check.

* [Sema] Diagnose passing integer to non-integer type parameter

This was previously missed, though would have been diagnosed later
as a requirement failure.

* [Parse] Split up `canParseType` 

While here, address the FIXME in `canParseTypeSimpleOrComposition`
and only check to see if we can parse a type-simple, including
`each`, `some`, and `any` for better recovery.

* Introduce type sugar for InlineArray

Parse e.g `[3 x Int]` as type sugar for InlineArray. Gated behind
an experimental feature flag for now.
2025-03-23 15:31:37 -07:00
Ben Barham
160ac826a2 Remove extraneous dump
Presumably these were originally used for debug purposes.

Resolves rdar://147660535.
2025-03-22 15:27:28 -07:00
Adrian Prantl
0db8d14204 [Debug Info] Add missing caching for types with no type sugar
This avoids redundant creation and uniquing of types in the case where
we only have a canonical name. Since the uniquing changes the type
graph this introduced the possibility for use-after-free if
IRGenDebugInfoImpl held on to a direct (non-tracking) DIType *.

rdar://146327709
2025-03-20 14:24:12 -07:00
Adrian Prantl
8e3d88f5d8 [Debug Info] Create all member types up front
when creating the members of a struct, to avoid problems when the type
graph changes due to type nodes being uniqued. It's not clear this can
actually happen, but it helps ruling this out as a failure cause.
2025-03-20 14:13:00 -07:00
Adrian Prantl
371e812e61 [Debug Info] Fix LLVM API misuse
DBuilder::replaceTemporary() can return a different pointer. In
practice this only happens when temporary and replacement are uniqued,
so that's probably how we got away with this in the past.
2025-03-20 11:18:37 -07:00
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
6e9faa1303 Merge pull request #79929 from adrian-prantl/146688269
[Debug Info] Prevent infinite recursion when emitting debug info
2025-03-13 08:47:00 -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
f5760ec3da Remove debugging code 2025-03-11 14:04:13 -07:00
Erik Eckstein
d225c47d25 AST: rename OpenArchetypeType -> ExistentialArchetypeType
NFC
2025-03-11 20:21:46 +01:00
Shubham Sandeep Rastogi
c2c5eb1334 [DebugInfo]Generate call-site information in swift
This patch adds support for emitting the flag
llvm::DINode::FlagAllCallsDescribed when generating LLVM IR from the
Swift compiler to get call-site information for swift source code.
2025-02-26 14:28:45 -08:00
Adrian Prantl
404ddc97ba [Debug Info] Avoid emitting a single fragment that covers the entire variable. 2025-02-17 14:54:58 -08: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