Commit Graph

7762 Commits

Author SHA1 Message Date
nate-chandler
b00b5aad4f Merge pull request #72646 from nate-chandler/bitwise-copyable/20240327/1
[BitwiseCopyable] Allow suppression via ~.
2024-04-18 07:05:10 -07:00
Karoy Lorentey
c6bc1965f6 [stdlib] Optional, Result: Try adding @_disfavoredOverload to work around a shadowing issue
The new ~Copyable generalizations have changed the function signature enough that alternative definitions of `map`/`flatMap` in existing code that used to be considered to shadow the originals no longer do so. This leads to use sites becoming ambiguous — a source break.

While we consider approaches to resolve this on the compiler side, let’s try slapping a `@_disfavoredOverload` on these and see if that helps.
2024-04-16 17:13:56 -07:00
Karoy Lorentey
153c001b15 [stdlib] Undo typed throws on withExtendedLifetime
https://github.com/apple/swift/pull/73045 has uncovered a compiler crash with existing code of this form:

       try withExtendedLifetime(statement) { // 💥silgen crash
            do {
                try dbPool.close()
                XCTFail("Expected Error")
            } catch DatabaseError.SQLITE_BUSY { }
        }

This patterns can happen with any of the newly typed throwing entry points, but the source compat suite only seems to have caught this with `withExtendedLifetime`; let’s see if we can get away with only rolling back this one.
2024-04-16 17:10:24 -07:00
Karoy Lorentey
fab25dc984 [stdlib] Optional, Result: Update borrowing switch syntax (_borrowing → borrowing) 2024-04-16 01:15:33 -07:00
Karoy Lorentey
5679bf6697 [stdlib] Generalize temporary allocations for noncopyable result types
We can’t do typed throws here yet. (They involve implicit stack allocations that interfere with the explicit stack allocation builtins.)
2024-04-16 01:15:33 -07:00
Karoy Lorentey
cafc99369b [stdlib] Round out ~Copyable generalizations in stdlib primitives
- `Optional.map`, `.flatMap`: Allow noncopyable results. Implement typed throws.

- `Result.map`, `.flatMap`: Allow noncopyable types for the new success.
- `Result.flatMapError`: Generalize for noncopyable Success.

- `Unsafe[Mutable][Buffer]Pointer.withMemoryRebound`: Alllow typed throws.
- `Unsafe[Mutable]BufferPointer: Generalize CustomDebugStringConvertible conformance for noncopyable `Element`s.

- `OpaquePointer.init(_: UnsafeMutablePointer)`, `.init(_: UnsafeMutablePointer?)`: Allow noncopyable pointee types.

- `ManagedBuffer.withUnsafeMutablePointerToHeader`, `.withUnsafeMutablePointerToElements`, `.withUnsafeMutablePointers`: Generalize for typed throws and noncopyable return types. Avoid `@_preInverseGenerics`.
- `ManagedBufferPointer`: Ditto.

- `withExtendedLifetime`: Use typed throws. Stop using `@_preInverseGenerics`.

rdar://117753275
2024-04-16 01:15:33 -07:00
Nate Chandler
eb1f0ac68a [BitwiseCopyable] Suppress via ~.
In addition to the existing language mechanism of
`@available(*, unavailable)`.
2024-04-15 16:46:24 -07:00
Nate Chandler
deeea710ae [NFC] stdlib: Separate type decl from members. 2024-04-15 16:46:00 -07:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Alex Martini
325e033547 Add initial reference for Copyable
Drawing from SE-0427.
2024-04-12 16:55:52 -07:00
Yuta Saito
10410f1030 Merge pull request #72973 from kateinoigakukun/yt/repair-embedded-wasm-class
[embedded][wasm] Fix missing putchar symbol in test
2024-04-12 00:06:35 +09:00
Yuta Saito
7a205dca32 [embedded] Use @_extern(c) instead of @_silgen_name for putchar 2024-04-11 02:55:23 +00:00
Kuba Mracek
8dfee7de2b [embedded] Conditionalize assert printing to debug assert config 2024-04-10 19:22:00 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Kuba Mracek
67f3d34d02 [embedded] Fix fatalError() to produce a trap in Release configurations 2024-04-09 11:36:39 -07:00
Kuba Mracek
309dbe1c1a [embedded] Make fatalError() in embedded Swift only print in non-production builds (-Onone or -assert-config Debug) 2024-04-09 11:36:38 -07:00
Kuba Mracek
757e4e56b0 [embedded] In -assert-config Debug, print errors in assertions, preconditions, fatalErrors 2024-04-09 11:36:21 -07:00
Yuta Saito
ef07102b88 Merge pull request #72891 from kateinoigakukun/yt/fix-wasm-float16 2024-04-10 01:01:58 +09:00
Erik Eckstein
ce33d47a4c stdlib: add the swift_clearSensitive runtime function 2024-04-09 12:01:10 +02:00
Yuta Saito
c32c7f55fe [wasm] Fix build failure due to lack of _Float16 support
WebAssembly does not support _Float16 type, so we need to guard the use
of the type. Unfortunately, Clang does not provide a good way to detect
the support of _Float16 type at compile time, so just disable for wasm
targets.
2024-04-07 16:34:11 +00:00
Stephen Canon
6ac852f3f4 Move Float16 print tests to their own file and test exhaustively (#72859)
We can easily test all 2**16 values, so let's do it. Also now _Float16 is properly supported in clang, so we can pass arguments to CPP that way, which lets us get snan right on more platforms.
2024-04-05 19:55:19 -04:00
Meghana Gupta
b3b2f37262 Merge pull request #72822 from stephentyrone/a-a-ambiguity-breaker-part-ii
Further ambiguity breakers for UDC & SEDC
2024-04-04 15:10:59 -07:00
Stephen Canon
cb400c61bb Add further ambiguity breakers for UDC & SEDC 2024-04-03 18:47:19 -04:00
Alejandro Alonso
e71a55eb19 Print a special message when we fail getting a keypath value 2024-04-03 15:35:55 -07:00
Stephen Canon
cbf9cb2734 Break ambiguity for types conforming to both UEC and SVEC (#72800)
* Break ambiguity for types conforming to both UEC and SVEC

If an encoding container conforms to _both_ UEC and SVEC and does not
itself implement support for [U]Int128, there is an ambiguity between
the two default implementations. Add additional defaults defined on
the intersection of the protocols to resolve this.

* Update abi tests for new ambiguity breakers.
2024-04-03 16:53:48 -04:00
Stephen Canon
a381589524 SE-0425 implementation (#72139) 2024-04-02 16:24:41 -04:00
Nate Cook
38e1370884 Revert "Revert count(where:)" (#70816)
* Revert "Revert count(where:)"

This reverts commit 779ea19a6a.

Now that SE-0220 has been re-accepted, this adds the `count(where:)` 
Sequence method to the standard library.
2024-03-29 13:53:53 -05:00
Joe Groff
233c1675cf Merge pull request #72647 from jckarter/borrowing-switch-expr-based-ownership
Alternative noncopyable switch design based on expression kind.
2024-03-28 14:44:16 -07:00
Alejandro Alonso
af11b95f4d Merge pull request #72656 from weissi/jw-fix-json
fix GroupInfo.json: was invalid JSON
2024-03-28 13:31:23 -07:00
Alejandro Alonso
07eb52a80d Merge pull request #72636 from Azoy/destroy-array-opt
[IRGen] Optimize Builtin.arrayDestroy when count is 1
2024-03-28 11:32:43 -07:00
Joe Groff
ba3494802a Alternative noncopyable switch design based on expression kind.
If an expression refers to noncopyable storage, then default to performing
a borrowing switch, where `let` bindings in patterns borrow out of the
matched value. If an expression refers to a temporary value or explicitly
uses the `consume` keyword, then perform a consuming switch, where
`let` bindings take ownership of corresponding parts of the matched value.
Allow `_borrowing` to still be used to explicitly bind a pattern variable
as a borrow, with no-implicit-copy semantics for copyable values.
2024-03-28 08:32:48 -07:00
Johannes Weiss
3f5c3244ce fix GroupInfo.json: was invalid JSON 2024-03-28 13:07:18 +00:00
Allan Shortlidge
37034282a1 stdlib: Adopt @_disallowFeatureSuppression(NoncopyableGenerics).
This prevents some re-declaration errors when building the standard library
from its `.swiftinterface` with older compilers.
2024-03-27 22:20:50 -07:00
Allan Shortlidge
a1dacc12d7 stdlib: Make typed throws ABI placeholders properly @usableFromInline.
Functions that are used in public `@inlinable` function bodies can't be marked
`@_spi` nor can they be made obsolete. Also, they must retain `rethrows` so
that use of these entry points from other `rethrows` functions is accepted.

Builds on https://github.com/apple/swift/pull/72365. Once we no longer have to
support pre-`$TypedThrows` compilers, all of this can be reverted.

Part of rdar://125138945
2024-03-27 14:57:56 -07:00
Alejandro Alonso
8ea3426273 Update comment about arrayDestroy in pointer 2024-03-27 14:02:06 -07:00
Kuba Mracek
37d9be636a [embedded] Handle NULL IVarDestroyers, expand test 2024-03-26 21:14:21 -07:00
Kuba Mracek
b8bd832fba [embedded] Add IVarDestroyers into class metadata, add support for throws in initializers 2024-03-26 20:52:17 -07:00
Kuba (Brecka) Mracek
c256c1f594 Merge pull request #72563 from kubamracek/embedded-isUniquelyReferenced_native
[embedded] Add swift_isUniquelyReferenced_native into the embedded runtime
2024-03-26 09:16:12 -07:00
Kuba Mracek
8f247e2d36 [embedded] Add swift_isUniquelyReferenced_native into the embedded runtime 2024-03-25 11:51:01 -07:00
Kuba (Brecka) Mracek
89cd62604b Merge pull request #72472 from kubamracek/embedded-keypaths
[embedded] Compile-time (literal) KeyPaths for Embedded Swift
2024-03-25 10:58:51 -07:00
Kuba Mracek
595ea991ce [embedded] Guard @_transparent in UnsafePointer APIs with #if 2024-03-24 18:12:23 -07:00
Karoy Lorentey
0885068325 [stdlib] Undo the generalization of Result.map & .flatMap for now
We didn’t do this for Optional’s equivalent methods yet, so it seems premature to do it for Result.
2024-03-20 18:42:07 -07:00
Kuba Mracek
b642d771be [embedded] Compile-time (literal) KeyPaths for Embedded Swift
Enable KeyPath/AnyKeyPath/PartialKeyPath/WritableKeyPath in Embedded Swift, but
for compile-time use only:

- Add keypath optimizations into the mandatory optimizations pipeline
- Allow keypath optimizations to look through begin_borrow, to make them work
  even in OSSA.
- If a use of a KeyPath doesn't optimize away, diagnose in PerformanceDiagnostics
- Make UnsafePointer.pointer(to:) transparent to allow the keypath optimization
  to happen in the callers of UnsafePointer.pointer(to:).
2024-03-20 15:35:46 -07:00
Stephen Canon
d24843eea0 Replace two reduces with explicit loops in SIMD implementations. (#72423)
* Replace two `reduce`s with explicit loops in SIMD implementations.

`reduce` has enough machinery that it pushes us over some inlining thresholds before optimizations happen, resulting in much worse codegen for String breadcrumbs. So a nice pickup there, but also generally applicable to other code as well.
2024-03-20 10:05:35 -04:00
Erik Eckstein
f6a28d81b0 stdlib: enable a check for a special case in Array.append(contentsOf:)
The check for the special case if the sequence is an Array was disabled in embedded swift.
It can be enabled because we now remove the cast after specialization.
Saves some code size when appending one array to another array.
2024-03-19 11:58:16 +01:00
Karoy Lorentey
f24e18cb01 Merge pull request #71688 from lorentey/noncopyable-primitives
[stdlib] Start adopting noncopyable generics in the stdlib
2024-03-18 20:45:24 -07:00
Allan Shortlidge
ca925ab379 stdlib: Resolve an un-mutated var warning.
NFC.
2024-03-18 16:33:17 -07:00
Karoy Lorentey
e88750eb0c [stdlib] Apply review notes from @glessard (thanks!) 2024-03-18 11:09:08 -07:00
Guillaume Lessard
3b09ecec74 [gardening] update copyright notice
[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice

[gardening] update copyright notice
2024-03-18 11:08:32 -07:00
Karoy Lorentey
afa459edd8 [stdlib] ManagedBuffer: Add @_preInverseGenerics for $Embedded 2024-03-18 11:08:32 -07:00