Skip to content

Commit f65fafb

Browse files
authored
Merge branch 'main' into wip-concurrency-assert-dispatch
2 parents 597841a + 5e92df0 commit f65fafb

File tree

1,232 files changed

+44020
-14878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,232 files changed

+44020
-14878
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,41 @@
5959
Having been [gated](https://github.com/apple/swift/pull/28171) behind a
6060
compiler warning since at least Swift 5.2, this syntax is now rejected.
6161

62+
* [#71075][]:
63+
64+
\_SwiftConcurrencyShims used to declare the `exit` function, even though it
65+
might not be available. The declaration has been removed, and must be imported
66+
from the appropriate C library module (e.g. Darwin or SwiftGlibc)
67+
68+
* [SE-0270][]:
69+
70+
The Standard Library now provides APIs for performing collection operations
71+
over noncontiguous elements. For example:
72+
73+
```swift
74+
var numbers = Array(1...15)
75+
76+
// Find the indices of all the even numbers
77+
let indicesOfEvens = numbers.indices(where: { $0.isMultiple(of: 2) })
78+
79+
// Perform an operation with just the even numbers
80+
let sumOfEvens = numbers[indicesOfEvens].reduce(0, +)
81+
// sumOfEvens == 56
82+
83+
// You can gather the even numbers at the beginning
84+
let rangeOfEvens = numbers.moveSubranges(indicesOfEvens, to: numbers.startIndex)
85+
// numbers == [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15]
86+
// numbers[rangeOfEvens] == [2, 4, 6, 8, 10, 12, 14]
87+
```
88+
89+
The standard library now provides a new `indices(where:)` function which creates
90+
a `RangeSet` - a new type representing a set of discontiguous indices. `RangeSet`
91+
is generic over its index type and can be used to execute operations over
92+
noncontiguous indices such as collecting, moving, or removing elements from a
93+
collection. Additionally, `RangeSet` is generic over any `Comparable` collection
94+
index and can be used to represent a selection of items in a list or a refinement
95+
of a filter or search result.
96+
6297
## Swift 5.10
6398

6499
* Swift 5.10 closes all known static data-race safey holes in complete strict
@@ -10088,4 +10123,5 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1008810123
[#57225]: <https://github.com/apple/swift/issues/57225>
1008910124
[#56139]: <https://github.com/apple/swift/issues/56139>
1009010125
[#70065]: <https://github.com/apple/swift/pull/70065>
10126+
[#71075]: <https://github.com/apple/swift/pull/71075>
1009110127
[swift-syntax]: https://github.com/apple/swift-syntax

CMakeLists.txt

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ include(FetchContent)
101101
check_language(Swift)
102102
if(CMAKE_Swift_COMPILER)
103103
enable_language(Swift)
104+
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION "${CMAKE_Swift_COMPILER_VERSION}")
104105
else()
105106
message(STATUS "WARNING! Did not find a host compiler swift?! Can not build
106107
any compiler host sources written in Swift")
108+
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION)
107109
endif()
108110

109111
# A convenience pattern to match Darwin platforms. Example:
@@ -215,18 +217,22 @@ option(SWIFT_BUILD_REMOTE_MIRROR
215217
"Build the Swift Remote Mirror Library"
216218
TRUE)
217219

220+
option(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER
221+
"Build the Swift External Generic Metadata Builder Library"
222+
TRUE)
223+
218224
option(SWIFT_BUILD_DYNAMIC_STDLIB
219225
"Build dynamic variants of the Swift standard library"
220226
TRUE)
221227

222228
option(SWIFT_BUILD_STATIC_STDLIB
223229
"Build static variants of the Swift standard library"
224230
FALSE)
225-
231+
226232
option(SWIFT_STDLIB_STATIC_PRINT
227233
"Build compile-time evaluated vprintf()"
228234
FALSE)
229-
235+
230236
option(SWIFT_STDLIB_ENABLE_UNICODE_DATA
231237
"Include Unicode data files in the standard library.
232238
NOTE: Disabling this will cause many String methods to crash."
@@ -460,6 +466,10 @@ set(SWIFT_DARWIN_MODULE_ARCHS "" CACHE STRING
460466
targets on Darwin platforms. These targets are in addition to the full \
461467
library targets.")
462468

469+
set(SWIFT_MIN_RUNTIME_VERSION "${DEFAULT_SWIFT_MIN_RUNTIME_VERSION}" CACHE STRING
470+
"Specify the minimum version of the runtime that we target when building \
471+
the compiler itself. This is used on non-Darwin platforms to ensure \
472+
that it's possible to build the compiler using host tools.")
463473

464474
#
465475
# User-configurable Android specific options.
@@ -639,6 +649,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
639649
"Enable experimental distributed actors and functions"
640650
FALSE)
641651

652+
option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
653+
"Enable experimental NoncopyableGenerics"
654+
FALSE)
655+
642656
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
643657
"Enable experimental string processing"
644658
FALSE)
@@ -647,6 +661,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION
647661
"Enable build of the Swift observation module"
648662
FALSE)
649663

664+
option(SWIFT_STDLIB_ENABLE_STRICT_CONCURRENCY_COMPLETE
665+
"Build the stdlib with -strict-concurrency=complete"
666+
FALSE)
667+
650668
option(SWIFT_ENABLE_SYNCHRONIZATION
651669
"Enable build of the Swift Synchronization module"
652670
FALSE)
@@ -1230,6 +1248,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12301248
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
12311249
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12321250
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1251+
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
12331252
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12341253
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
12351254
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")
@@ -1251,6 +1270,11 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
12511270
message(STATUS "")
12521271
endif()
12531272

1273+
if(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER)
1274+
message(STATUS "Building Swift External Generic Metadata Builder for SDKs: ${SWIFT_SDKS}")
1275+
message(STATUS "")
1276+
endif()
1277+
12541278
#
12551279
# Find required dependencies.
12561280
#

SwiftCompilerSources/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ function(add_swift_compiler_modules_library name)
106106
"-Xcc" "-std=c++17"
107107
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
108108
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
109+
109110
if (NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
111+
if(SWIFT_MIN_RUNTIME_VERSION)
112+
list(APPEND swift_compile_options
113+
"-Xfrontend" "-min-runtime-version"
114+
"-Xfrontend" "${SWIFT_MIN_RUNTIME_VERSION}")
115+
endif()
110116
list(APPEND swift_compile_options "-Xfrontend" "-disable-implicit-string-processing-module-import")
111117
endif()
112118

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/BooleanLiteralFolding.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,30 @@ import SIL
4646
let booleanLiteralFolding = FunctionPass(name: "boolean-literal-folding") {
4747
(function: Function, context: FunctionPassContext) in
4848

49+
var changed = false
4950
for block in function.blocks {
5051
if let condBr = block.terminator as? CondBranchInst {
51-
fold(condBranch: condBr, context)
52+
changed = fold(condBranch: condBr, context) || changed
5253
}
5354
}
55+
if changed {
56+
_ = context.removeDeadBlocks(in: function)
57+
}
5458
}
5559

56-
private func fold(condBranch: CondBranchInst, _ context: FunctionPassContext) {
60+
private func fold(condBranch: CondBranchInst, _ context: FunctionPassContext) -> Bool {
5761
guard let structExtract = condBranch.condition as? StructExtractInst,
5862
let initApply = structExtract.struct as? ApplyInst,
5963
initApply.hasSemanticsAttribute("bool.literal_init"),
6064
initApply.arguments.count == 2,
6165
let literal = initApply.arguments[0] as? IntegerLiteralInst,
6266
let literalValue = literal.value else
6367
{
64-
return
68+
return false
6569
}
6670

6771
let builder = Builder(before: condBranch, context)
6872
builder.createBranch(to: literalValue == 0 ? condBranch.falseBlock : condBranch.trueBlock)
6973
context.erase(instruction: condBranch)
74+
return true
7075
}

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ swift_compiler_sources(Optimizer
1818
DeinitDevirtualizer.swift
1919
InitializeStaticGlobals.swift
2020
LetPropertyLowering.swift
21+
LifetimeDependenceDiagnostics.swift
2122
ObjectOutliner.swift
2223
ObjCBridgingOptimization.swift
2324
MergeCondFails.swift

0 commit comments

Comments
 (0)