Skip to content

Commit 9f8e6de

Browse files
committed
Merge branch 'main' into nested-protocols
2 parents d8282c4 + 72337ef commit 9f8e6de

File tree

2,655 files changed

+123988
-62461
lines changed

Some content is hidden

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

2,655 files changed

+123988
-62461
lines changed

.github/CODEOWNERS

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
/include/swift/DependencyScan @artemcm
6363
/include/swift/Driver @artemcm
6464
# TODO: /include/swift/IRGen/
65-
/include/swift/IDE/ @ahoppen @bnbarham @rintaro
65+
/include/swift/IDE/ @ahoppen @bnbarham @rintaro @hamishknight
6666
/include/swift/Index/ @bnbarham
6767
/include/swift/Refactoring @ahoppen @bnbarham
6868
/include/swift/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
@@ -100,8 +100,8 @@
100100
/lib/DriverTool/swift_symbolgraph_extract_main.cpp @QuietMisdreavus
101101
/lib/Frontend/*ModuleInterface* @artemcm @tshortli
102102
# TODO: /lib/IRGen/
103-
/lib/IDE/ @ahoppen @bnbarham @rintaro
104-
/lib/IDETool/ @ahoppen @bnbarham @rintaro
103+
/lib/IDE/ @ahoppen @bnbarham @rintaro @hamishknight
104+
/lib/IDETool/ @ahoppen @bnbarham @rintaro @hamishknight
105105
/lib/Index/ @bnbarham
106106
/lib/Refactoring/ @ahoppen @bnbarham
107107
/lib/IRGen/*Coverage* @hamishknight
@@ -139,24 +139,26 @@
139139
# stdlib
140140
# TODO: /stdlib/
141141
/stdlib/public/Backtracing/ @al45tair
142+
/stdlib/public/Concurrency/ @ktoso @kavon
142143
/stdlib/public/Cxx/ @zoecarver @hyp @egorzhdan
143144
/stdlib/public/Distributed/ @ktoso
144145
/stdlib/public/Windows/ @compnerd
145146
/stdlib/public/libexec/swift-backtrace/ @al45tair
146147

147148
# test
148149
/test/ASTGen/ @zoecarver @CodaFi
150+
/test/Concurrency/ @ktoso @kavon
149151
/test/Constraints/ @hborla @xedin
150152
/test/DebugInfo/ @adrian-prantl
151153
/test/Distributed/ @ktoso
152154
/test/Driver/ @artemcm
153155
/test/Driver/static* @MaxDesiatov @etcwilde
154156
/test/Generics/ @hborla @slavapestov
155157
# TODO: /test/IRGen/
156-
/test/IDE/ @ahoppen @bnbarham @rintaro
158+
/test/IDE/ @ahoppen @bnbarham @rintaro @hamishknight
157159
/test/Index/ @bnbarham
158160
/test/refactoring/ @ahoppen @bnbarham
159-
/test/SourceKit/ @ahoppen @bnbarham @rintaro
161+
/test/SourceKit/ @ahoppen @bnbarham @rintaro @hamishknight
160162
/test/Interop/ @zoecarver @hyp @egorzhdan
161163
/test/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
162164
/test/Profiler @hamishknight
@@ -177,9 +179,10 @@
177179

178180
# tools
179181
# TODO: /tools
180-
/tools/SourceKit @ahoppen @bnbarham @rintaro
182+
/tools/SourceKit @ahoppen @bnbarham @rintaro @hamishknight
181183
/tools/lldb-moduleimport-test/ @adrian-prantl
182-
/tools/swift-ide-test @ahoppen @bnbarham @rintaro
184+
/tools/swift-ide-test @ahoppen @bnbarham @rintaro @hamishknight
185+
/tools/swift-inspect @mikeash @al45tair @compnerd
183186
/tools/swift-refactor @ahoppen @bnbarham
184187

185188
# unittests
@@ -188,7 +191,7 @@
188191
/unittests/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
189192
# TODO: /unittests/SIL/
190193
/unittests/Sema/ @hborla @xedin
191-
/unittests/SourceKit/ @ahoppen @bnbarham @rintaro
194+
/unittests/SourceKit/ @ahoppen @bnbarham @rintaro @hamishknight
192195
# TODO: /unittests/stdlib/
193196

194197
# userdocs
@@ -209,7 +212,7 @@
209212

210213
# validation-test
211214
# TODO: /validation-test/IRGen/
212-
/validation-test/IDE/ @ahoppen @bnbarham @rintaro
215+
/validation-test/IDE/ @ahoppen @bnbarham @rintaro @hamishknight
213216
/validation-test/Parse/ @ahoppen @bnbarham @CodaFi @DougGregor @rintaro
214217
# TODO: /validation-test/SIL/
215218
# TODO: /validation-test/SILGen/

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,11 @@ option(SWIFT_THREADING_PACKAGE
646646
Valid package names are 'pthreads', 'darwin', 'linux', 'win32', 'c11', 'none'
647647
or the empty string for the SDK default.")
648648

649+
option(SWIFT_THREADING_HAS_DLSYM
650+
"Enable the use of the dlsym() function. This gets used to provide TSan
651+
support on some platforms."
652+
TRUE)
653+
649654
option(SWIFT_ENABLE_MACCATALYST
650655
"Build the Standard Library and overlays with MacCatalyst support"
651656
FALSE)
@@ -1043,6 +1048,14 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
10431048
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
10441049
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
10451050

1051+
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
1052+
set(SWIFT_HOST_VARIANT "wasi" CACHE STRING
1053+
"Deployment OS for Swift host tools (the compiler) [wasi]")
1054+
1055+
configure_sdk_unix("WASI" "wasm32")
1056+
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
1057+
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
1058+
10461059
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
10471060

10481061
set(SWIFT_HOST_VARIANT "macosx" CACHE STRING

SwiftCompilerSources/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ function(add_swift_compiler_modules_library name)
8787
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
8888
endif()
8989

90+
if(NOT LLVM_ENABLE_ASSERTIONS)
91+
list(APPEND swift_compile_options "-Xcc" "-DNDEBUG")
92+
endif()
93+
9094
if(NOT SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
9195
list(APPEND swift_compile_options "-Xfrontend" "-disable-legacy-type-info")
9296
endif()
@@ -227,7 +231,7 @@ else()
227231
add_subdirectory(Sources)
228232

229233
# TODO: generate this dynamically through the modulemap; this cannot use `sed`
230-
# as that is not available on all paltforms (e.g. Windows).
234+
# as that is not available on all platforms (e.g. Windows).
231235
#
232236
# step 1: generate a dummy source file, which just includes all headers
233237
# defined in include/swift/module.modulemap

SwiftCompilerSources/Sources/Basic/SourceLoc.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public struct SourceLoc {
2727
guard bridged.isValid() else {
2828
return nil
2929
}
30+
#if $NewCxxMethodSafetyHeuristics
31+
self.locationInFile = bridged.getOpaquePointerValue().assumingMemoryBound(to: UInt8.self)
32+
#else
3033
self.locationInFile = bridged.__getOpaquePointerValueUnsafe().assumingMemoryBound(to: UInt8.self)
34+
#endif
3135
}
3236

3337
public var bridged: swift.SourceLoc {
@@ -57,9 +61,15 @@ public struct CharSourceRange {
5761
}
5862

5963
public init?(bridged: swift.CharSourceRange) {
64+
#if $NewCxxMethodSafetyHeuristics
65+
guard let start = SourceLoc(bridged: bridged.getStart()) else {
66+
return nil
67+
}
68+
#else
6069
guard let start = SourceLoc(bridged: bridged.__getStartUnsafe()) else {
6170
return nil
6271
}
72+
#endif
6373
self.init(start: start, byteLength: bridged.getByteLength())
6474
}
6575

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,34 @@ public struct StringRef : CustomStringConvertible, NoReflectionChildren {
6666
public var description: String { string }
6767

6868
public var count: Int {
69+
#if $NewCxxMethodSafetyHeuristics
70+
Int(_bridged.bytes_end() - _bridged.bytes_begin())
71+
#else
6972
Int(_bridged.__bytes_endUnsafe() - _bridged.__bytes_beginUnsafe())
73+
#endif
7074
}
7175

7276
public subscript(index: Int) -> UInt8 {
77+
#if $NewCxxMethodSafetyHeuristics
78+
let buffer = UnsafeBufferPointer<UInt8>(start: _bridged.bytes_begin(),
79+
count: count)
80+
#else
7381
let buffer = UnsafeBufferPointer<UInt8>(start: _bridged.__bytes_beginUnsafe(),
7482
count: count)
83+
#endif
7584
return buffer[index]
7685
}
7786

7887
public static func ==(lhs: StringRef, rhs: StaticString) -> Bool {
88+
#if $NewCxxMethodSafetyHeuristics
89+
let lhsBuffer = UnsafeBufferPointer<UInt8>(
90+
start: lhs._bridged.bytes_begin(),
91+
count: lhs.count)
92+
#else
7993
let lhsBuffer = UnsafeBufferPointer<UInt8>(
8094
start: lhs._bridged.__bytes_beginUnsafe(),
8195
count: lhs.count)
96+
#endif
8297
return rhs.withUTF8Buffer { (rhsBuffer: UnsafeBufferPointer<UInt8>) in
8398
if lhsBuffer.count != rhsBuffer.count { return false }
8499
return lhsBuffer.elementsEqual(rhsBuffer, by: ==)

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,6 @@ import SIL
1616
struct AliasAnalysis {
1717
let bridged: BridgedAliasAnalysis
1818

19-
func mayRead(_ inst: Instruction, fromAddress: Value) -> Bool {
20-
switch bridged.getMemBehavior(inst.bridged, fromAddress.bridged) {
21-
case .MayRead, .MayReadWrite, .MayHaveSideEffects:
22-
return true
23-
default:
24-
return false
25-
}
26-
}
27-
28-
func mayWrite(_ inst: Instruction, toAddress: Value) -> Bool {
29-
switch bridged.getMemBehavior(inst.bridged, toAddress.bridged) {
30-
case .MayWrite, .MayReadWrite, .MayHaveSideEffects:
31-
return true
32-
default:
33-
return false
34-
}
35-
}
36-
37-
func mayReadOrWrite(_ inst: Instruction, address: Value) -> Bool {
38-
switch bridged.getMemBehavior(inst.bridged, address.bridged) {
39-
case .MayRead, .MayWrite, .MayReadWrite, .MayHaveSideEffects:
40-
return true
41-
default:
42-
return false
43-
}
44-
}
45-
4619
/// Returns the correct path for address-alias functions.
4720
static func getPtrOrAddressPath(for value: Value) -> SmallProjectionPath {
4821
let ty = value.type
@@ -63,7 +36,7 @@ struct AliasAnalysis {
6336
static func register() {
6437
BridgedAliasAnalysis.registerAnalysis(
6538
// getMemEffectsFn
66-
{ (bridgedCtxt: BridgedPassContext, bridgedVal: BridgedValue, bridgedInst: BridgedInstruction) -> swift.MemoryBehavior in
39+
{ (bridgedCtxt: BridgedPassContext, bridgedVal: BridgedValue, bridgedInst: BridgedInstruction, complexityBudget: Int) -> swift.MemoryBehavior in
6740
let context = FunctionPassContext(_bridged: bridgedCtxt)
6841
let inst = bridgedInst.instruction
6942
let val = bridgedVal.value
@@ -74,7 +47,8 @@ struct AliasAnalysis {
7447
case let builtin as BuiltinInst:
7548
return getMemoryEffect(ofBuiltin: builtin, for: val, path: path, context).bridged
7649
default:
77-
if val.at(path).isEscaping(using: EscapesToInstructionVisitor(target: inst, isAddress: true), context) {
50+
if val.at(path).isEscaping(using: EscapesToInstructionVisitor(target: inst, isAddress: true),
51+
complexityBudget: complexityBudget, context) {
7852
return .MayReadWrite
7953
}
8054
return .None
@@ -119,6 +93,35 @@ struct AliasAnalysis {
11993
}
12094
}
12195

96+
extension Instruction {
97+
func mayRead(fromAddress: Value, _ aliasAnalysis: AliasAnalysis) -> Bool {
98+
switch aliasAnalysis.bridged.getMemBehavior(bridged, fromAddress.bridged) {
99+
case .MayRead, .MayReadWrite, .MayHaveSideEffects:
100+
return true
101+
default:
102+
return false
103+
}
104+
}
105+
106+
func mayWrite(toAddress: Value, _ aliasAnalysis: AliasAnalysis) -> Bool {
107+
switch aliasAnalysis.bridged.getMemBehavior(bridged, toAddress.bridged) {
108+
case .MayWrite, .MayReadWrite, .MayHaveSideEffects:
109+
return true
110+
default:
111+
return false
112+
}
113+
}
114+
115+
func mayReadOrWrite(address: Value, _ aliasAnalysis: AliasAnalysis) -> Bool {
116+
switch aliasAnalysis.bridged.getMemBehavior(bridged, address.bridged) {
117+
case .MayRead, .MayWrite, .MayReadWrite, .MayHaveSideEffects:
118+
return true
119+
default:
120+
return false
121+
}
122+
}
123+
}
124+
122125
private func getMemoryEffect(ofApply apply: ApplySite, for address: Value, path: SmallProjectionPath, _ context: FunctionPassContext) -> SideEffects.Memory {
123126
let calleeAnalysis = context.calleeAnalysis
124127
let visitor = SideEffectsVisitor(apply: apply, calleeAnalysis: calleeAnalysis, isAddress: true)

SwiftCompilerSources/Sources/Optimizer/DataStructures/Stack.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ struct Stack<Element> : CollectionLikeSequence {
4747

4848
mutating func next() -> Element? {
4949
let end = (slab.data == lastSlab.data ? endIndex : slabCapacity)
50-
if index < end {
51-
let elem = Stack.bind(slab)[index]
52-
index += 1
53-
54-
if index >= end && slab.data != lastSlab.data {
55-
slab = slab.getNext()
56-
index = 0
57-
}
58-
return elem
50+
51+
guard index < end else { return nil }
52+
53+
let elem = Stack.bind(slab)[index]
54+
index += 1
55+
56+
if index >= end && slab.data != lastSlab.data {
57+
slab = slab.getNext()
58+
index = 0
5959
}
60-
return nil
60+
return elem
6161
}
6262
}
6363

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ swift_compiler_sources(Optimizer
1111
CleanupDebugSteps.swift
1212
ComputeEscapeEffects.swift
1313
ComputeSideEffects.swift
14+
DeadStoreElimination.swift
1415
InitializeStaticGlobals.swift
1516
ObjectOutliner.swift
1617
ObjCBridgingOptimization.swift
1718
MergeCondFails.swift
1819
NamedReturnValueOptimization.swift
20+
RedundantLoadElimination.swift
1921
ReleaseDevirtualizer.swift
2022
SimplificationPasses.swift
2123
StackPromotion.swift
24+
StripObjectHeaders.swift
2225
)

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private struct CollectedEffects {
113113

114114
case let store as StoreInst:
115115
addEffects(.write, to: store.destination)
116-
if store.destinationOwnership == .assign {
116+
if store.storeOwnership == .assign {
117117
addDestroyEffects(ofAddress: store.destination)
118118
}
119119

@@ -454,7 +454,7 @@ private struct ArgumentEscapingWalker : ValueDefUseWalker, AddressDefUseWalker {
454454
case let load as LoadInst:
455455
if !address.value.hasTrivialType &&
456456
// In non-ossa SIL we don't know if a load is taking.
457-
(!function.hasOwnership || load.ownership == .take) {
457+
(!function.hasOwnership || load.loadOwnership == .take) {
458458
foundTakingLoad = true
459459
}
460460
return .continueWalk

0 commit comments

Comments
 (0)