Commit Graph

6583 Commits

Author SHA1 Message Date
Meghana Gupta
961e6ea104 Merge pull request #76294 from meg-gupta/rewritenext
Rewrite UnsafeRawBufferPointer.Iterator.next
2024-09-20 12:10:39 -07:00
Konrad `ktoso` Malawski
d89347bed0 Merge branch 'main' into wip-experimental-isolated-deinit 2024-09-20 18:34:45 +09:00
Hiroshi Yamauchi
dedfb9e0ab Ensure that bridged types are indirectly returned on Windows ARM64
On Windows ARM64, how a struct value type is returned is sensitive to
conditions including whether a user-defined constructor exists,
etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the
non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++)
side and a crash.

Following https://github.com/swiftlang/swift/pull/76433 add
constructors to several bridged C++ struct/class types so that the
calling convention matches.

This is a partial fix for https://github.com/swiftlang/swift/issues/74866
2024-09-19 16:00:15 -07:00
swift-ci
ae4fee5d4e Merge remote-tracking branch 'origin/main' into rebranch 2024-09-19 13:54:31 -07:00
Doug Gregor
6039df3a34 Merge pull request #76565 from DougGregor/remove-if-config
Remove IfConfigDecl from the AST
2024-09-19 13:49:03 -07:00
swift-ci
df338c19a8 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-19 09:34:45 -07:00
Michael Gottesman
92a3e53b02 Merge pull request #76434 from gottesmm/pr-3e00ab647dbc50beececb8c8cf096921bdf7acd3
[concurrency] Represent a SILFunction without isolation as std::optional<ActorIsolation> instead of ActorIsolation::Unspecified.
2024-09-19 09:17:52 -07:00
Kuba Mracek
6b9a3051e3 [embedded] Introduce class-bound existentials into Embedded Swift
Motivated by need for protocol-based dynamic dispatch, which hasn't been possible in Embedded Swift due to a full ban on existentials. This lifts that restriction but only for class-bound existentials: Class-bound existentials are already (even in desktop Swift) much more lightweight than full existentials, as they don't need type metadata, their containers are typically 2 words only (reference + wtable pointer), don't incur copies (only retains+releases).

Included in this PR:
[x] Non-generic class-bound existentials, executable tests for those.
[x] Extension methods on protocols and using those from a class-bound existential.
[x] RuntimeEffects now differentiate between Existential and ExistentialClassBound.
[x] PerformanceDiagnostics don't flag ExistentialClassBound in Embedded Swift.
[x] WTables are generated in IRGen when needed.

Left for follow-up PRs:
[ ] Generic classes support
2024-09-19 07:49:50 -07:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07:00
Michael Gottesman
a0088327d4 [concurrency] Represent a SILFunction without isolation as std::optional<ActorIsolation> instead of ActorIsolation::Unspecified.
The reason why is that we want to distinguish inbetween SILFunction's that are
marked as unspecified by SILGen and those that are parsed from textual SIL that
do not have any specified isolation. This will make it easier to write nice
FileCheck tests against SILGen output on what is the inferred isolation for
various items.

NFCI.
2024-09-18 11:23:22 -07:00
swift-ci
b92d239d41 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 04:55:19 -07:00
Egor Zhdan
ad503afc72 Merge pull request #76515 from swiftlang/egorzhdan/scs-reduce-unsafe
[cxx-interop][SwiftCompilerSources] Reduce the number of `SWIFT_IMPORT_UNSAFE` attributes
2024-09-18 12:42:54 +01:00
swift-ci
055c9b69a7 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-17 06:56:16 -07:00
Slava Pestov
6b57a9f208 Merge pull request #76511 from slavapestov/fix-issue-62061
SIL: Handle ProtocolCompositionType in SubstFunctionTypePatternVisitor
2024-09-17 09:43:00 -04:00
Egor Zhdan
3b540ddbeb [cxx-interop][SwiftCompilerSources] Remove SWIFT_IMPORT_UNSAFE on constructors
These attributes have no effect on C++ constructors.
2024-09-17 13:38:48 +01:00
Egor Zhdan
9aee3ccac0 [cxx-interop][SwiftCompilerSources] Remove incorrect SWIFT_IMPORT_UNSAFE
`swift::Decl` and its inheritors should be treated as foreign reference types in Swift, meaning pointers to them (`Decl*`) should be mapped to Swift classes. This can be done by applying `SWIFT_UNSAFE_REFERENCE` attribute to the `swift::Decl` types. However, at the moment these functions don't seem to be used from Swift, so this change just removes the `SWIFT_IMPORT_UNSAFE` attributes.
2024-09-17 13:23:49 +01:00
Egor Zhdan
9ee34df6df [cxx-interop][SwiftCompilerSources] Remove redundant SWIFT_IMPORT_UNSAFE
`OptionalInt` is not an unsafe type in Swift, so the attribute has no effect.
2024-09-17 13:15:40 +01:00
Egor Zhdan
0efa7f90ef [cxx-interop][SwiftCompilerSources] Do not use SWIFT_IMPORT_UNSAFE with SILDebugLocation
`SWIFT_IMPORT_UNSAFE` is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

`SILDebugLocation` is better described as a self-contained Swift type.

Similar to 35263ef9.
2024-09-17 13:07:57 +01:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Slava Pestov
5147adcca5 SIL: Handle ProtocolCompositionType in SubstFunctionTypePatternVisitor
Fixes https://github.com/swiftlang/swift/issues/62061.
2024-09-16 21:20:55 -04:00
Ben Barham
a7b50f357f Merge remote-tracking branch 'origin/main' into manual-main-merge
Conflicts:
  - `lib/Driver/ToolChains.cpp` conflicting with the `addAllArgs` rename
    for multiple options
2024-09-16 13:53:18 -07:00
Egor Zhdan
586ac0953c Merge pull request #76408 from swiftlang/egorzhdan/scs-owned-string
[cxx-interop][SwiftCompilerSources] Do not use `SWIFT_IMPORT_UNSAFE` with `BridgedOwnedString`
2024-09-16 20:00:20 +01:00
Hiroshi Yamauchi
7633c00764 Merge pull request #76433 from hjyamauchi/issue74866-2
Ensure that BridgedTypeArray is indirectly returned
2024-09-16 11:46:29 -07:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Hiroshi Yamauchi
f815e1429e Ensure that BridgedTypeArray is indirectly returned
On Windows ARM64, how a struct value type is returned is sensitive to
conditions including whether a user-defined constructor exists,
etc. See

https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values

That caused a calling convention mismatch between the
non-USED_IN_CPP_SOURCE (Swift) side and the USE_IN_CPP_SOURCE (C++)
side and a crash.

Add this constructor so that the calling convention matches.

This is a fix for the OnoneSimplification crash in

https://github.com/swiftlang/swift/issues/74866#issuecomment-2319618579

and is a partial fix for

https://github.com/swiftlang/swift/issues/74866#issuecomment-2319618579
2024-09-12 10:46:55 -07:00
Egor Zhdan
35263ef9d6 [cxx-interop][SwiftCompilerSources] Do not use SWIFT_IMPORT_UNSAFE with BridgedOwnedString
`SWIFT_IMPORT_UNSAFE` is an escape hatch that can be used to make the Swift compiler ignore its usual safety heuristics for C++ types.

`BridgedOwnedString` fits into the definition of a self-contained C++ type in Swift: it manages the lifetimes of its own fields.

This removes the usages of `SWIFT_IMPORT_UNSAFE` for C++ functions that return `BridgedOwnedString`, and annotates `BridgedOwnedString` as a self-contained type.
2024-09-11 19:58:14 +01:00
Alejandro Alonso
7219daf418 Collect metadata from like type and add type information when GEPing into raw layouts 2024-09-05 18:04:47 -07:00
swift-ci
da55e84c74 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 15:35:33 -07:00
Alejandro Alonso
45d7ea39a5 Merge pull request #75518 from Azoy/integer-generics
Implement Value generics
2024-09-05 15:33:46 -07:00
Meghana Gupta
423aa007f3 Add LLVM_ATTRIBUTE_USED to DominanceInfo::dump
This function was unavailable in the debugger because it was getting
optimized away.
2024-09-05 14:19:22 -07:00
swift-ci
5c71a3605f Merge remote-tracking branch 'origin/main' into rebranch 2024-09-04 18:14:28 -07:00
Alejandro Alonso
b35ac50d3c Optimize TypeValueInst in Swift 2024-09-04 15:13:48 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
swift-ci
b29ebad446 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-04 12:04:17 -07:00
Slava Pestov
b1e0e776b4 AST: Simplify SubstitutionMap::lookupConformance() 2024-09-04 14:57:38 -04:00
Slava Pestov
a3c0e225a7 Merge pull request #76238 from slavapestov/existential-signature-rework-part-3
Allow type variables to appear inside opened existential archetypes
2024-09-04 14:53:18 -04:00
Slava Pestov
c47f352df7 AST: Use new form of getOpenedExistentialSignature() in GenericEnvironment::forOpenedExistential() 2024-09-04 10:42:18 -04:00
swift-ci
756fe355fa Merge remote-tracking branch 'origin/main' into rebranch 2024-09-03 22:34:34 -07:00
Alex Hoppen
791c1fddc8 Merge pull request #76237 from swiftlang/revert-60057-mpokhylets/isolated-deinit
Revert "Isolated synchronous deinit"
2024-09-03 22:17:09 -07:00
Slava Pestov
35488edefb SIL: Use getDefinedOpenedArchetype() to simplify SILCloner 2024-09-04 00:00:35 -04:00
swift-ci
50d4698d95 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-03 20:36:09 -07:00
Slava Pestov
3f317a10fc Merge pull request #76216 from slavapestov/existential-signature-rework-part-2
Convert more callers to use new form of ASTContext::getOpenedExistentialSignature()
2024-09-03 23:22:00 -04:00
Alex Hoppen
c5aa49ba64 Revert "Isolated synchronous deinit" 2024-09-03 18:11:26 -07:00
Slava Pestov
e3ff6f0697 AST: Fiddle with GenericEnvironment::forOpenedExistential() again 2024-09-03 17:31:26 -04:00
swift-ci
dd7533d4e7 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-03 09:33:55 -07:00
Konrad `ktoso` Malawski
c86e4a8738 Merge pull request #60057 from nickolas-pohilets/mpokhylets/isolated-deinit
Co-authored-by: Konrad `ktoso` Malawski <ktoso@apple.com>
2024-09-04 01:16:56 +09:00
swift-ci
c5f3efc44b Merge remote-tracking branch 'origin/main' into rebranch 2024-09-02 18:56:47 -07:00
Kavon Farvardin
274f13da9a SIL: re-downgrade assertion due to issue 2024-09-02 14:44:45 -07:00
Konrad `ktoso` Malawski
c55ad6fa88 Merge branch 'main' into mpokhylets/isolated-deinit 2024-09-02 23:16:17 +09:00