Skip to content

Commit 3315cab

Browse files
authored
Merge branch 'main' into cal--fix-70089
2 parents 97178b2 + c96803f commit 3315cab

File tree

919 files changed

+18211
-8896
lines changed

Some content is hidden

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

919 files changed

+18211
-8896
lines changed

CMakeLists.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,11 @@ How swift-C++ bridging code is compiled:
360360
]=] DEFAULT)
361361

362362
option(SWIFT_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX})
363-
set(SWIFT_COPY_OR_SYMLINK "copy")
363+
set(SWIFT_COPY_OR_SYMLINK "copy_if_different")
364+
set(SWIFT_COPY_OR_SYMLINK_DIR "copy_directory")
364365
if(SWIFT_USE_SYMLINKS)
365366
set(SWIFT_COPY_OR_SYMLINK "create_symlink")
367+
set(SWIFT_COPY_OR_SYMLINK_DIR "create_symlink")
366368
endif()
367369

368370
# The following only works with the Ninja generator in CMake >= 3.0.
@@ -487,6 +489,14 @@ set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
487489
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
488490
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
489491

492+
#
493+
# User-configurable WebAssembly specific options.
494+
#
495+
496+
option(SWIFT_ENABLE_WASI_THREADS
497+
"Build the Standard Library with WASI threads support"
498+
FALSE)
499+
490500
#
491501
# User-configurable Darwin-specific options.
492502
#
@@ -657,6 +667,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
657667
"Enable experimental NoncopyableGenerics"
658668
FALSE)
659669

670+
option(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES
671+
"Enable experimental NonescapableTypes"
672+
FALSE)
673+
660674
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
661675
"Enable experimental string processing"
662676
FALSE)
@@ -965,6 +979,18 @@ endif()
965979
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
966980
"Build Swift with a non-default linker")
967981

982+
include(CheckLinkerFlag)
983+
984+
# Apple's linker complains about duplicate libraries, which CMake likes to do
985+
# to support ELF platforms. To silence that warning, we can use
986+
# -no_warn_duplicate_libraries, but only in versions of the linker that
987+
# support that flag.
988+
if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
989+
check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
990+
else()
991+
set(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
992+
endif()
993+
968994
#
969995
# Enable additional warnings.
970996
#
@@ -1253,6 +1279,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12531279
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12541280
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
12551281
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
1282+
message(STATUS "NonEscapableTypes Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES}")
12561283
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12571284
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
12581285
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
| **Amazon Linux 2** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64)|
2020
| **Universal Base Image 9** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubi-9/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubi-9)|
2121

22+
**Cross-Compilation Targets**
23+
24+
| **Target** | **Build** |
25+
|:---:|:---:|
26+
| **wasm32-unknown-wasi** |[![Build Status](https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04)|
27+
2228
**Swift Community-Hosted CI Platforms**
2329

2430
| **OS** | **Architecture** | **Build** |
2531
|---|:---:|:---:|
26-
|**[Ubuntu 20.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/wasm32_ubuntu_20.04.json)** | wasm32 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly)|
2732
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
2833
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|
2934
|**[Windows 2019 (VS 2019)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_windows_2019_VS2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019)|

SwiftCompilerSources/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ function(add_swift_compiler_modules_library name)
155155
list(APPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
156156
endif()
157157
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
158-
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
159158
# NOTE: prepending allows SWIFT_COMPILER_SOURCES_SDK_FLAGS to override the
160159
# resource directory if needed.
161-
list(PREPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../lib/swift")
160+
list(PREPEND sdk_option "-resource-dir" "${SWIFTLIB_DIR}")
162161
endif()
163162
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
164163
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -232,6 +231,9 @@ function(add_swift_compiler_modules_library name)
232231
importedHeaderDependencies
233232
COMMENT "Building swift module ${module}")
234233

234+
if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
235+
add_dependencies(${dep_target} swift-stdlib-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
236+
endif()
235237
set("${module}_dep_target" ${dep_target})
236238
set(all_module_targets ${all_module_targets} ${dep_target})
237239
endforeach()

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/AllocVectorLowering.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private struct ComputeNonEscapingLiferange : EscapeVisitorWithResult {
414414
if dominates {
415415
liferange.insert(user)
416416
}
417-
if !apply.type.isEscapable {
417+
if !apply.isEscapable {
418418
return .abort
419419
}
420420
return .ignore

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/InitializeStaticGlobals.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ private func getSequenceOfElementStores(firstStore: StoreInst) -> ([StoreInst],
113113
return nil
114114
}
115115
let structAddr = elementAddr.struct
116-
if structAddr.type.isMoveOnly {
116+
let structType = structAddr.type
117+
if structType.isMoveOnly {
117118
return nil
118119
}
119-
guard let fields = structAddr.type.getNominalFields(in: firstStore.parentFunction) else {
120+
if structType.nominal.isStructWithUnreferenceableStorage {
121+
return nil
122+
}
123+
guard let fields = structType.getNominalFields(in: firstStore.parentFunction) else {
120124
return nil
121125
}
122126
let numElements = fields.count

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceDiagnostics.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ let lifetimeDependenceDiagnosticsPass = FunctionPass(
3535
log(" --- Diagnosing lifetime dependence in \(function.name)")
3636
log("\(function)")
3737

38-
for argument in function.arguments where !argument.type.isEscapable {
38+
for argument in function.arguments
39+
where !argument.type.isEscapable(in: function)
40+
{
3941
// Indirect results are not checked here. Type checking ensures
4042
// that they have a lifetime dependence.
4143
if let lifetimeDep = LifetimeDependence(argument, context) {

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LifetimeDependenceScopeFixup.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ private func log(_ message: @autoclosure () -> String) {
3131
let lifetimeDependenceScopeFixupPass = FunctionPass(
3232
name: "lifetime-dependence-scope-fixup")
3333
{ (function: Function, context: FunctionPassContext) in
34+
if !context.options.hasFeature(.NonescapableTypes) {
35+
return
36+
}
3437
log(" --- Scope fixup for lifetime dependence in \(function.name)")
3538

3639
let localReachabilityCache = LocalVariableReachabilityCache()

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyBuiltin.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ extension BuiltinInst : OnoneSimplifyable {
4444
.AllocVector,
4545
.IsPOD:
4646
optimizeArgumentToThinMetatype(argument: 0, context)
47-
case .CreateAsyncTask:
48-
// In embedded Swift, CreateAsyncTask needs a thin metatype
49-
if context.options.enableEmbeddedSwift {
50-
optimizeArgumentToThinMetatype(argument: 1, context)
51-
}
5247
case .ICMP_EQ:
5348
constantFoldIntegerEquality(isEqual: true, context)
5449
case .ICMP_NE:

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private func optimizeFunctionsTopDown(using worklist: inout FunctionWorklist,
5656
f.set(isPerformanceConstraint: true, context)
5757
}
5858

59-
optimize(function: f, context, &worklist)
59+
optimize(function: f, context, moduleContext, &worklist)
6060
}
6161

6262
// Generic specialization takes care of removing metatype arguments of generic functions.
@@ -73,7 +73,7 @@ fileprivate struct PathFunctionTuple: Hashable {
7373
var function: Function
7474
}
7575

76-
private func optimize(function: Function, _ context: FunctionPassContext, _ worklist: inout FunctionWorklist) {
76+
private func optimize(function: Function, _ context: FunctionPassContext, _ moduleContext: ModulePassContext, _ worklist: inout FunctionWorklist) {
7777
var alreadyInlinedFunctions: Set<PathFunctionTuple> = Set()
7878

7979
var changed = true
@@ -92,11 +92,11 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ work
9292
// Embedded Swift specific transformations
9393
case let alloc as AllocRefInst:
9494
if context.options.enableEmbeddedSwift {
95-
specializeVTableAndAddEntriesToWorklist(for: alloc.type, in: function, context, &worklist)
95+
specializeVTableAndAddEntriesToWorklist(for: alloc.type, in: function, context, moduleContext, &worklist)
9696
}
9797
case let metatype as MetatypeInst:
9898
if context.options.enableEmbeddedSwift {
99-
specializeVTableAndAddEntriesToWorklist(for: metatype.type, in: function, context, &worklist)
99+
specializeVTableAndAddEntriesToWorklist(for: metatype.type, in: function, context, moduleContext, &worklist)
100100
}
101101
case let classMethod as ClassMethodInst:
102102
if context.options.enableEmbeddedSwift {
@@ -133,13 +133,21 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ work
133133
}
134134
}
135135

136-
private func specializeVTableAndAddEntriesToWorklist(for type: Type, in function: Function, _ context: FunctionPassContext, _ worklist: inout FunctionWorklist) {
137-
guard let vtable = context.specializeVTable(for: type, in: function) else {
136+
private func specializeVTableAndAddEntriesToWorklist(for type: Type, in function: Function,
137+
_ context: FunctionPassContext, _ moduleContext: ModulePassContext,
138+
_ worklist: inout FunctionWorklist) {
139+
let vTablesCountBefore = moduleContext.vTables.count
140+
141+
guard context.specializeVTable(for: type, in: function) != nil else {
138142
return
139143
}
140144

141-
for entry in vtable.entries {
142-
worklist.pushIfNotVisited(entry.function)
145+
// More than one new vtable might have been created (superclasses), process them all
146+
let vTables = moduleContext.vTables
147+
for i in vTablesCountBefore ..< vTables.count {
148+
for entry in vTables[i].entries {
149+
worklist.pushIfNotVisited(entry.function)
150+
}
143151
}
144152
}
145153

SwiftCompilerSources/Sources/Optimizer/Utilities/LifetimeDependenceUtils.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ extension LifetimeDependence {
219219
//
220220
// TODO: handle indirect results
221221
init?(unsafeApplyResult value: Value, _ context: some Context) {
222-
if value.type.isEscapable {
222+
if value.isEscapable {
223223
return nil
224224
}
225225
if (value.definingInstruction as! FullApplySite).hasResultDependence {
@@ -832,7 +832,7 @@ extension LifetimeDependenceDefUseWalker {
832832
mutating func walkDownUses(of value: Value, using operand: Operand?)
833833
-> WalkResult {
834834
// Only track ~Escapable and @noescape types.
835-
if value.type.mayEscape {
835+
if value.mayEscape {
836836
return .continueWalk
837837
}
838838
return walkDownUsesDefault(forwarding: value, using: operand)
@@ -857,10 +857,10 @@ extension LifetimeDependenceDefUseWalker {
857857
if let apply = operand.instruction as? FullApplySite {
858858
return visitAppliedUse(of: operand, by: apply)
859859
}
860-
if operand.instruction is ReturnInst, !operand.value.type.isEscapable {
860+
if operand.instruction is ReturnInst, !operand.value.isEscapable {
861861
return returnedDependence(result: operand)
862862
}
863-
if operand.instruction is YieldInst, !operand.value.type.isEscapable {
863+
if operand.instruction is YieldInst, !operand.value.isEscapable {
864864
return yieldedDependence(result: operand)
865865
}
866866
return escapingDependence(on: operand)
@@ -1025,10 +1025,10 @@ extension LifetimeDependenceDefUseWalker {
10251025
assert(!mdi.isUnresolved && !mdi.isNonEscaping,
10261026
"should be handled as a dependence by AddressUseVisitor")
10271027
}
1028-
if operand.instruction is ReturnInst, !operand.value.type.isEscapable {
1028+
if operand.instruction is ReturnInst, !operand.value.isEscapable {
10291029
return returnedDependence(result: operand)
10301030
}
1031-
if operand.instruction is YieldInst, !operand.value.type.isEscapable {
1031+
if operand.instruction is YieldInst, !operand.value.isEscapable {
10321032
return yieldedDependence(result: operand)
10331033
}
10341034
return escapingDependence(on: operand)
@@ -1088,19 +1088,19 @@ extension LifetimeDependenceDefUseWalker {
10881088
case let .argument(arg):
10891089
if arg.convention.isIndirectIn || arg.convention.isInout {
10901090
allocation = arg
1091-
} else if arg.convention.isIndirectOut, !arg.type.isEscapable {
1091+
} else if arg.convention.isIndirectOut, !arg.isEscapable {
10921092
return returnedDependence(address: arg, using: operand)
10931093
}
10941094
break
10951095
case .global, .class, .tail, .yield, .pointer, .unidentified:
10961096
break
10971097
}
10981098
if let allocation = allocation {
1099-
if !allocation.type.objectType.isEscapable {
1099+
if !allocation.isEscapable {
11001100
return visitLocalStore(allocation: allocation, storedOperand: operand, storeAddress: address)
11011101
}
11021102
}
1103-
if address.type.objectType.isEscapable {
1103+
if address.isEscapable {
11041104
return .continueWalk
11051105
}
11061106
return escapingDependence(on: operand)
@@ -1179,13 +1179,13 @@ extension LifetimeDependenceDefUseWalker {
11791179
// If the lifetime dependence is scoped, then we can ignore it
11801180
// because a mark_dependence [nonescaping] represents the
11811181
// dependence.
1182-
if let result = apply.singleDirectResult, !result.type.isEscapable {
1182+
if let result = apply.singleDirectResult, !result.isEscapable {
11831183
if dependentUse(of: operand, into: result) == .abortWalk {
11841184
return .abortWalk
11851185
}
11861186
}
11871187
for resultAddr in apply.indirectResultOperands
1188-
where !resultAddr.value.type.isEscapable {
1188+
where !resultAddr.value.isEscapable {
11891189
if visitStoredUses(of: operand, into: resultAddr.value) == .abortWalk {
11901190
return .abortWalk
11911191
}

0 commit comments

Comments
 (0)