Commit Graph

4501 Commits

Author SHA1 Message Date
Mishal Shah
fe97b6d055 Fix notification username in Branches.md 2025-11-12 08:41:24 -08:00
Mishal Shah
c345a31182 Update notification instructions in Branches.md
Clarified notification instructions for pull requests.
2025-11-12 08:41:01 -08:00
Anthony Latsis
8992ea82a2 Merge pull request #85433 from swiftlang/jepa-main4
AST: Rename `GenericContext::isGeneric` to `hasGenericParamList`
2025-11-11 21:12:34 +00:00
Anthony Latsis
bda6edb85c AST: Rename GenericContext::isGeneric to hasGenericParamList
`isGeneric` is a misleading name because this method checks for the
existence of a `GenericParamList`, which is not implied by genericity.
2025-11-11 15:55:16 +00:00
Slava Pestov
2349b5f6cf docs: Update generics book for 2025
- Revised "Substitution Maps" chapter:
  - New "Subclassing" section
  - New "SIL Type Lowering" section
- New "Opaque Result Types" chapter
- Various smaller edits

New PDF will be available shortly at https://download.swift.org/docs/assets/generics.pdf.
2025-11-11 08:34:36 -05:00
Alfonso Urdaneta
ae9fede33e Replace screenshot to reflect apple/swift -> swiftlang/swift 2025-11-06 03:32:48 +00:00
Slava Pestov
a81a3d37b0 docs: Remove obsolete example from TypeChecker.md
Swift has not had user-defined conversions since before Swift 1.0.

Remove the running example from the discussion of locators. This
probably makes the explanation too opaque, but the old explanation
was useless because it was out of date.

I'll add a proper example later.
2025-11-04 18:31:37 -05:00
John McCall
8d231d20c6 Rewrite StackNesting to be a non-iterative single-pass algorithm.
The previous algorithm was doing an iterative forward data flow analysis
followed by a reverse data flow analysis. I suspect the history here is that
it was a reverse analysis, and that didn't really work for infinite loops,
and so complexity accumulated.

The new algorithm is quite straightforward and relies on the allocations
being properly jointly post-dominated, just not nested. We simply walk
forward through the blocks in consistent-with-dominance order, maintaining
the stack of active allocations and deferring deallocations that are
improperly nested until we deallocate the allocations above it. The only
real subtlety is that we have to delay walking into dead-end regions until
we've seen all of the edges into them, so that we can know whether we have
a coherent stack state in them. If the state is incoherent, we need to
remove any deallocations of previous allocations because we cannot talk
correctly about what's on top of the stack.

The reason I'm doing this, besides it just being a simpler and hopefully
faster algorithm, is that modeling some of the uses of the async stack
allocator properly requires builtins that cannot just be semantically
reordered. That should be somewhat easier to handle with the new approach,
although really (1) we should not have runtime functions that need this and
(2) we're going to need a conservatively-correct solution that's different
from this anyway because hoisting allocations is *also* limited in its own
way.

I've attached a rather pedantic proof of the correctness of the algorithm.

The thing that concerns me most about the rewritten pass is that it isn't
actually validating joint post-dominance on input, so if you give it bad
input, it might be a little mystifying to debug the verifier failures.
2025-11-03 11:51:17 -08:00
Slava Pestov
e18c0c4cea docs: Update Lexicon.md to clarify 'canonical type', and add 'reduced type' 2025-10-31 10:58:22 -04:00
Aidan Hall
a8cef4451a Merge pull request #84513 from aidan-hall/pack-opt
Optimize Specializations of Variadic Generics by Eliminating Parameter Packs
2025-10-31 11:24:04 +00:00
Slava Pestov
e413739b98 docs: Document the fields of the score in TypeChecker.md 2025-10-30 14:46:05 -04:00
Slava Pestov
4127a4e86c docs: Document Unsafe*Pointer conversions in TypeChecker.md 2025-10-30 14:46:05 -04:00
Aidan Hall
8632e58825 Create Pack Specialisation pass 2025-10-30 14:28:16 +00:00
Jamie
251a3f4c39 [docs]: minor typo fixes/cleanups in TypeChecker.md 2025-10-29 07:43:57 -05:00
Carl Peto
5f45e5a704 Merge pull request #85181 from carlpeto/fix-docs-backtrace-options
Fix a few small discrepancies in the docs about options for backtrace.
2025-10-29 10:46:04 +00:00
Slava Pestov
efcb8c6350 Link to Embedded Swift docs and 'Compiling Swift Generics' from docs/README.md 2025-10-28 22:31:11 -04:00
Slava Pestov
83b9bd6588 docs: Fresh coat of paint for TypeChecker.md 2025-10-28 22:31:11 -04:00
Carl Peto
825d82fe79 Update docs/Backtracing.rst
Co-authored-by: Alastair Houghton <alastair@alastairs-place.net>
2025-10-28 21:52:47 +00:00
Carl Peto
43c84ea6e6 Update docs/Backtracing.rst
Co-authored-by: Alastair Houghton <alastair@alastairs-place.net>
2025-10-28 21:52:34 +00:00
Carl Peto
fdbbf31d04 Update docs/Backtracing.rst
Co-authored-by: Alastair Houghton <alastair@alastairs-place.net>
2025-10-28 21:52:14 +00:00
Carl Peto
a2c24eafc7 Fix a few small discrepancies in the docs about options for backtrace. 2025-10-28 17:48:23 +00:00
Kuba (Brecka) Mracek
eb23d3bc0a Merge pull request #85074 from kubamracek/section
SE-0492: Stabilize @_section/@_used into @section/@used
2025-10-24 12:29:48 -07:00
Meghana Gupta
9fed0413f0 [NFC] Add documentation 2025-10-23 05:19:16 -07:00
Kuba Mracek
adeb40f261 SE-0492: Stabilize @_section/@_used into @section/@used
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492.

Major parts:
- Renamed @_section to @section and @_used to @used
- Removed the SymbolLinkageMarkers experimental feature
- Added parsing support for the old underscored names with deprecation warnings
- Updated all tests and examples to use the new attribute names
- Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm)
- Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules
- Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
2025-10-22 16:05:39 -07:00
Meghana Gupta
06eb315612 Update mangling for borrow and mutate accessors 2025-10-20 09:05:36 -07:00
Michael Gottesman
fe9c21fd87 [sil] Add a new instruction cast_implicit_actor_to_optional_actor.
This instruction converts Builtin.ImplicitActor to Optional<any Actor>. In the
process of doing so, it masks out the bits we may have stolen from the witness
table pointer of Builtin.ImplicitActor. The bits that we mask out are the bottom
two bits of the top nibble of the TBI space on platforms that support TBI (that
is bit 60,61 on arm64). On platforms that do not support TBI, we just use the
bottom two tagged pointer bits (0,1).

By using an instruction, we avoid having to represent the bitmasking that we are
performing at the SIL level and can instead just make the emission of the
bitmasking an IRGen detail. It also allows us to move detection if we are
compiling for AArch64 to be an IRGen flag instead of a LangOpts flag.

The instruction is a guaranteed forwarding instruction since we want to treat
its result as a borrowed projection from the Builtin.ImplicitActor.
2025-10-16 10:52:04 -07:00
Michael Gottesman
2fa3908e94 [concurrency] Add a new type Builtin.ImplicitActor.
This is currently not wired up to anything. I am going to wire it up in
subsequent commits.

The reason why we are introducing this new Builtin type is to represent that we
are going to start stealing bits from the protocol witness table pointer of the
Optional<any Actor> that this type is bitwise compatible with. The type will
ensure that this value is only used in places where we know that it will be
properly masked out giving us certainty that this value will not be used in any
manner without it first being bit cleared and transformed back to Optional<any
Actor>.
2025-10-16 10:51:13 -07:00
Doug Gregor
3e1ea3c0f7 [SIL] Add asmname attribute to SIL functions and global variables
The asmname attribute allows one to specify the name that will be used
when lowering a given SIL declaration to LLVM IR. It is not currently
exposed in the surface language.

Make sure this attribute round-trips through the parser and
serialization.

Part of rdar://137014448O.
2025-10-15 20:44:09 -07:00
John McCall
46623cb6c7 Merge pull request #84811 from rjmccall/verify-dead-end-edges
Strengthen the SIL verifier's rules for edges into dead-end regions
2025-10-11 18:16:56 -04:00
John McCall
f3c9ab8d50 Document SIL's dominance rules, which apparently we've never done. 2025-10-11 02:12:19 -04:00
Max Desiatov
db21bc20ea Merge pull request #84399 from MaxDesiatov/docs-wasm-swift-sdk
docs/WebAssembly.md: update Swift SDK build instructions

Swift SDKs require Swift SDK Generator to be built with its dependencies. Additionally, now that tests for Wasm stdlib run by default, we should include required tools. Embedded Swift build is also enabled in the documented invocation.
2025-10-10 23:20:38 +01:00
Mishal Shah
9d9116ed86 Merge pull request #84650 from rjmansfield/update-CI-md
Remove CentOS 7 and Ubuntu 18.04 from ContinuousIntegration.md.
2025-10-07 14:06:45 -07:00
eeckstein
401a2ac2bc Merge pull request #84704 from eeckstein/closure-specialization
ClosureSpecialization: support for OSSA and a big overhaul
2025-10-07 06:59:08 +02:00
Mishal Shah
ee04cb84b2 Merge pull request #84696 from valeriyvan/Generics-typos 2025-10-06 07:57:15 -07:00
Erik Eckstein
89bba668e2 Mangling: add a closure specialization mangling for arguments which specialize for the same closure as a previous argument
For example:
```
  %1 = partial_apply %closure
  apply %f(%1, %1)    // first argument: `.closure(%1)`
                      // second argument: `.previousArgumentIndex(0)`
```
2025-10-06 09:47:41 +02:00
Slava Pestov
ee156f2f12 Merge pull request #84689 from jamieQ/patch-2
[docs]: minor edits to 'existential types' chapter of generics book
2025-10-05 13:45:31 -04:00
Valeriy Van
5e098ff3af Fix typos in docs/Generics 2025-10-05 12:24:02 +02:00
Jake Petroules
4e8761a2cb Remove trailing spaces in Windows build docs (#84693)
This changes the meaning of the command, causing the remaining arguments
to be truncated.
2025-10-05 02:51:04 -07:00
Jamie
feead0cb22 [docs]: minor edits to 'existential types' chapter of generics book
fixed a couple typos encountered
2025-10-04 05:43:42 -05:00
Ryan Mansfield
5ea2bc9c71 Remove CentOS 7 and Ubuntu 18.04 from ContinuousIntegration.md.
Add Ubuntu 24.04.
2025-10-02 11:45:21 -04:00
Max Desiatov
2987ec80ec docs/WebAssembly.md: provide Swift SDK installation step 2025-09-19 17:30:16 +01:00
Max Desiatov
c2ca497571 docs/WebAssembly.md: update Swift SDK build instructions
Swift SDKs require Swift SDK Generator to be built with its dependencies. Additionally, now that tests for Wasm stdlib run by default, we should include required tools. Embedded Swift build is also enabled in the documented invocation.
2025-09-19 16:36:48 +01:00
Kavon Farvardin
2dea3ca3fc sil: load [copy] affects reference counting
Based on what I see from OwnershipModelEliminator,
`%x = load [copy] %y` can turn into a plain load
followed by a retain of the loaded value.

See `NonTrivialLoadableTypeLowering::emitLoad`
2025-09-16 15:25:20 -07:00
Meghana Gupta
c764244df0 Merge pull request #84180 from meg-gupta/borrowandmutatepr
Add preliminary support for borrow accessors
2025-09-15 10:01:15 -07:00
Meghana Gupta
aeac529925 [NFC] Add notes on self argument of borrow accessor being non-lexical 2025-09-14 23:38:18 -07:00
Hamish Knight
8e84e6a50d [docs] Update RequestEvaluator.md
The request evaluator is no longer new, and we've since implemented
per-request caching.
2025-09-12 20:39:58 +01:00
Meghana Gupta
28c4595735 Add mangling support for borrow/mutate accessors 2025-09-09 14:30:34 -07:00
Andrew Trick
592642087f Merge pull request #84010 from atrick/lifedep-mutating-default
@_lifetime defaults
2025-09-04 15:44:46 -07:00
Erik Eckstein
1a4bd76f95 Mangling: add specialization mangling for more complex constant propagated function arguments
So far, constant propagated arguments could only be builtin literals.
Now we support arbitrary structs (with constant arguments), e.g. `Int`.
This requires a small addition in the mangling scheme for function specializations.
Also, the de-mangling tree now looks a bit different to support a "tree" of structs and literals.
2025-09-04 08:15:44 +02:00
Andrew Trick
84a4b328ec Lifetime inference test case improvements.
Cleanup the tests so we can cross reference them with the documentation.

Update the tests to allow multiple annotations and defaults.
2025-09-03 22:42:13 -07:00