Commit Graph

1826 Commits

Author SHA1 Message Date
Mykola (Nickolas) Pokhylets
31470bbd1e Merge pull request #82732 from nickolas-pohilets/mpokhylets/weak-let-feature
Wrap SE-0481 into an upcoming feature until source incompatibilities are resolved
2025-08-14 23:59:28 +02:00
Hamish Knight
396a6a8fe6 Enable InlineArray type sugar
Promote it from an experimental feature.

rdar://155607927
2025-08-04 15:16:30 +01:00
Mykola Pokhylets
89f8f8b9bf Wrap only changes related to the closure frontend logic 2025-08-02 20:24:46 +02:00
Mykola Pokhylets
ae48446716 Wrap SE-0481 into an upcoming feature until source incompatibilities are resolved 2025-08-02 20:24:21 +02: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
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
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
Slava Pestov
9033198674 ASTDemangler: Round-trip @isolated @sil_implicit_leading_param parameter attributes
We sometimes mangle SILFunctionTypes when generating debug info
for reabstraction thunks, and these can have various exotic
parameter and result attributes. Two recent additions were
never plumbed through the mangler, causing assertion failures
when emitting debug info.

Fixes rdar://153730847.
2025-06-27 10:56:12 -04:00
Erik Eckstein
5b9c206059 Optimizer: remove don't use locationOfNextNonMetaInstruction for getting Builder locations from instructions
This does not work in some situations.
2025-06-20 08:15:00 +02:00
eeckstein
a33ff9879a Merge pull request #81969 from eeckstein/temp-lvalue-elimination
Optimizer: improve TempLValueOpt
2025-06-06 15:30:29 +02:00
Mykola (Nickolas) Pokhylets
87e536ebec Merge pull request #80440 from nickolas-pohilets/mpokhylets/weak-let 2025-06-05 09:59:33 +02:00
Erik Eckstein
2b9b2d243c Optimizer: improve TempLValueOpt
* re-implement the pass in swift
* support alloc_stack liveranges which span over multiple basic blocks
* support `load`-`store` pairs, copying from the alloc_stack (in addition to `copy_addr`)

Those improvements help to reduce temporary stack allocations, especially for InlineArrays.

rdar://151606382
2025-06-05 06:45:18 +02:00
Slava Pestov
f6f0d75263 Merge pull request #81843 from slavapestov/hamish-fuzzer-fixes
Hamish fuzzer fixes
2025-05-31 12:28:56 -04:00
Slava Pestov
a0e7cce51d ASTDemangler: Use associated type declarations instead of identifiers as keys 2025-05-30 16:27:01 -04:00
Slava Pestov
14f6dbfc3a Add tests suggested by @AnthonyLatsis 2025-05-30 11:32:03 -04:00
Hamish Knight
5d1f219acb Change InlineArray sugar separator x -> of 2025-05-30 13:50:22 +01:00
eeckstein
ddca2bae98 Merge pull request #81706 from eeckstein/mandatory-temprvalue-elimination
Optimizer: Improve performance of large InlineArrays at Onone
2025-05-26 07:56:42 +02:00
Slava Pestov
52f54534f3 Merge pull request #76705 from slavapestov/existential-parameterized-composition
Allow existential parameterized compositions: `any P<A> & Q`
2025-05-23 21:26:50 -04: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
Slava Pestov
4338a55154 ASTDemangler: Add support for constrained existential compositions 2025-05-23 14:14:23 -04:00
Erik Eckstein
198d4ab0bb Optimizer: run TempRValueElimination also at Onone
Introduce a new pass MandatoryTempRValueElimination, which works as the original TempRValueElimination, except that it does not remove any alloc_stack instruction which are associated with source variables.

Running this pass at Onone helps to reduce copies of large structs, e.g. InlineArrays or structs containing InlineArrays.
Copying large structs can be a performance problem, even at Onone.

rdar://151629149
2025-05-23 18:56:56 +02:00
Mykola Pokhylets
de3a87c0ab Merge branch 'main' into mpokhylets/weak-let 2025-05-23 17:26:49 +02: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
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
Mykola Pokhylets
04166e21c9 Fixed some tests
Remaining failures:

SILGen/unowned-class-bound-generic-parameter.swift
2025-05-19 17:03:59 +02:00
Mykola Pokhylets
3e0de8672a Removed the feature and made changes unconditional 2025-05-15 10:52:09 +02:00
Mykola Pokhylets
5a69c8ebdb Added REQUIRES: swift_feature_WeakLet 2025-05-15 10:26:27 +02:00
Mykola Pokhylets
26106107eb Updated existing tests to run with feature enabled 2025-05-15 10:26:27 +02:00
Anthony Latsis
55e5618eab [test] Match nocapture to succeed both on main and rebranch
Both the syntax and relative order of the LLVM `nocapture` parameter
attribute changed upstream in 29441e4f5fa5f5c7709f7cf180815ba97f611297.
To reduce conflicts with rebranch, adjust FileCheck patterns to expect
both syntaxes and orders anywhere the presence of the attribute is not
critical to the test. These changes are temporary and will be cleaned
up once rebranch is merged into main.
2025-05-08 23:52:43 +01:00
Anthony Latsis
17fc00f8a7 [test] IRGen: Adjust FileCheck patterns for new nuw attribute in upstream LLVM
This attribute was introduced in
7eca38ce76d5d1915f4ab7e665964062c0b37697 (llvm-project).

Match it using a wildcard regex, since it is not relevant to these
tests.

This is intended to reduce future conflicts with rebranch.
2025-05-04 03:28:56 +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
Augusto Noronha
6abbc0d754 [DebugInfo] Use underlying type of global variables with opaque type
rdar://144881938
2025-03-31 15:52:09 -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
Shubham Sandeep Rastogi
6f09b80aaa Merge pull request #79833 from rastogishubham/FixHopToExe
[DebugInfo] Use Stmt EndLoc if SILLocation passed in is the Stmt EndLoc.
2025-03-19 12:02:28 -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
Shubham Sandeep Rastogi
7a6070e79c [DebugInfo] Use Stmt EndLoc if SILLocation passed in is the Stmt EndLoc.
When creating an ExtendedASTNodeLoc from a SILLocation, if the
SILLocation passed in belongs to a swift::Stmt, we only ever use the
Stmt's StartLoc for the SourceLocation. If the SILLocation passed in,
has a SourceLocation that matches the EndLoc of the Stmt, we should
correctly set the primary ASTNodeTy PointerUnion's integer to 1, to
denote that the SourceLocation dervied from the Stmt points to the
EndLoc.
2025-03-13 12:39:32 -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
Rintaro Ishizaki
7e6d4d3cb5 [Tests] Mark 2 tests require 'embedded_stdlib'
These tests require Embedded stdlib:

  DebugInfo/value-generics-embedded.swift
  Macros/macro_unique_name_embedded.swift
2025-03-11 13:25:30 -07:00
Alejandro Alonso
d0513a7aec Merge pull request #79665 from Azoy/value-generics-no-more-experiment
[AST] Make ValueGenerics feature always available
2025-03-10 15:14:34 -07:00
Slava Pestov
a03b8ee6aa AST: Allow mangling LocatableType in DWARF mode
Fixes rdar://problem/145954323.
2025-03-04 22:00:44 -05:00
Alejandro Alonso
c1bb143648 Make ValueGenerics feature always available 2025-02-27 10:03:37 -08: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
Shubham Sandeep Rastogi
52a5ed8646 Pass correct SubExpr as source location when emitting Load of LValue.
When emitting an LValue of a LoadExpr during SILGen, the Expression
passed as a SILLocation for the LValue was the parent LoadExpr instead
of the SubExpr that contains the LValue for the load. This leads to
the SILLocation to be marked as implicit, because a LoadExpr is always
an implicit expression.

An implicit SILLocation is not emitted when doing IRGen as it is
considered to be hidden from debug info and thus we lose the debug
location for the LValue of a LoadExpr.

This patch fixes this issue.
2025-02-21 09:16:30 -08:00
Shubham Sandeep Rastogi
092068340e Add option -sil-print-debuginfo-verbose
The option -sil-print-debuginfo-verbose will print the values of the
fields, implicit, and autoGenerated for a SILLocation, as well as
whether the SILLocation is considered hidden from debug information
by calling SILLocation::isHiddenFromDebugInfo()
2025-02-20 13:26:35 -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
Alejandro Alonso
e4fb1f6761 Rename Slab to InlineArray 2025-02-11 10:26:44 -08:00
Erik Eckstein
ba4081ee76 Optimizer: replace PredictableMemoryAccessOptimizations with MandatoryRedundantLoadElimination in the pass pipeline
PredictableMemoryAccessOptimizations has become unmaintainable as-is.
RedundantLoadElimination does (almost) the same thing as PredictableMemoryAccessOptimizations.
It's not as powerful but good enough because PredictableMemoryAccessOptimizations is actually only needed for promoting integer values for mandatory constant propagation.
And most importantly: RedundantLoadElimination does not insert additional copies which was a big problem in PredictableMemoryAccessOptimizations.

Fixes rdar://142814676
2025-02-07 11:30:35 +01:00
Adrian Prantl
85faa52009 Merge pull request #79085 from adrian-prantl/143833326
[Debug info] Emit bound generic class type parameters when emitting A…
2025-02-03 10:04:28 -08:00