Skip to content

Commit 5cc83cc

Browse files
authored
Merge branch 'main' into swift-inspect-android
2 parents 9604994 + 87d6979 commit 5cc83cc

File tree

541 files changed

+11540
-5074
lines changed

Some content is hidden

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

541 files changed

+11540
-5074
lines changed

CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
747747
"Enable experimental SwiftParser validation by default"
748748
FALSE)
749749

750-
option(SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS
751-
"Enable experimental safe wrappers around external functions"
752-
FALSE)
753-
754750
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
755751
"Build SourceKit" TRUE
756752
"SWIFT_ENABLE_DISPATCH" FALSE)
@@ -1397,7 +1393,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
13971393
message(STATUS "Observation Support: ${SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION}")
13981394
message(STATUS "Synchronization Support: ${SWIFT_ENABLE_SYNCHRONIZATION}")
13991395
message(STATUS "Volatile Support: ${SWIFT_ENABLE_VOLATILE}")
1400-
message(STATUS "Pointer Bounds Support: ${SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS}")
14011396
message(STATUS "")
14021397
else()
14031398
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
@@ -1616,7 +1611,8 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16161611
-DCMAKE_Swift_COMPILER:FILEPATH=$<IF:$<BOOL:${CMAKE_CROSSCOMPILING}>,${CMAKE_Swift_COMPILER},$<PATH:REPLACE_FILENAME,$<TARGET_FILE:swift-frontend>,swiftc>>
16171612
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
16181613
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1619-
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS})
1614+
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
1615+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM})
16201616
if(NOT ${CMAKE_CROSSCOMPILING})
16211617
add_dependencies("${stdlib_target}" swift-frontend)
16221618
endif()

Runtimes/Core/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
# Catalyst Support
2929
# -- Will need shadow invocations to generate swiftmodules for Swift parts
3030
# Install *.abi.json, swiftdoc, and swiftsourceinfo
31-
# Pointer bounds (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)
3231

3332
cmake_minimum_required(VERSION 3.26...3.29)
3433

@@ -87,7 +86,6 @@ defaulted_option(SwiftCore_ENABLE_OVERRIDABLE_RETAIN_RELEASE "Enable override ho
8786
defaulted_option(SwiftCore_ENABLE_MALLOC_TYPE "Enable malloc type information")
8887
defaulted_option(SwiftCore_ENABLE_RUNTIME_OS_VERSIONING "Enable runtime OS version detection")
8988
defaulted_option(SwiftCore_ENABLE_STATIC_PRINT "Disable full print")
90-
defaulted_option(SwiftCore_ENABLE_UNICODE_DATA "Embed Unicode info in Swift Core")
9189
defaulted_option(SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS "Resolve absolute function pointer as identity")
9290
defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtime backdeployment")
9391
defaulted_option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Assumes the presence of os_log(3) and the os_signpost(3) API.")
@@ -129,6 +127,7 @@ add_compile_options(
129127
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
130128
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
131129
$<$<COMPILE_LANGUAGE:CXX>:-funwind-tables>
130+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<NOT:$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>>>:SHELL:-Xfrontend -disable-objc-interop>"
132131
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<PLATFORM_ID:Windows>>:SHELL:-Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules>"
133132
$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>)
134133

Runtimes/Core/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ add_library(swiftCore
148148
Slice.swift
149149
SmallString.swift
150150
Sort.swift
151+
Span/Span.swift
152+
Span/RawSpan.swift
151153
StaticString.swift
152154
StaticPrint.swift
153155
Stride.swift

SwiftCompilerSources/Sources/AST/Registration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public func registerAST() {
4949
}
5050

5151
private func registerDecl<T: AnyObject>(_ cl: T.Type) {
52-
String(describing: cl)._withBridgedStringRef { nameStr in
52+
"\(cl)"._withBridgedStringRef { nameStr in
5353
let metatype = unsafeBitCast(cl, to: SwiftMetatype.self)
5454
registerBridgedDecl(nameStr, metatype)
5555
}

SwiftCompilerSources/Sources/AST/SubstitutionMap.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,14 @@ public struct SubstitutionMap: CustomStringConvertible {
5656
return Conformance(bridged: bridgedSubs.getConformance(index))
5757
}
5858
}
59+
60+
public var replacementTypes: TypeArray {
61+
TypeArray(bridged: bridged.getReplacementTypes())
62+
}
63+
64+
/// The single replacement type if it's guarnateed that the substitution map has a single replacement type.
65+
public var replacementType: Type {
66+
assert(replacementTypes.count == 1)
67+
return replacementTypes[0]
68+
}
5969
}

SwiftCompilerSources/Sources/AST/Type.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public struct Type: CustomStringConvertible, NoReflectionChildren {
4646
/// A Type that is statically known to be canonical.
4747
/// For example, typealiases are resolved.
4848
public struct CanonicalType: CustomStringConvertible, NoReflectionChildren {
49+
public enum TraitResult {
50+
case isNot
51+
case canBe
52+
case `is`
53+
}
54+
4955
public let bridged: BridgedCanType
5056

5157
public init(bridged: BridgedCanType) { self.bridged = bridged }
@@ -63,4 +69,38 @@ public struct CanonicalType: CustomStringConvertible, NoReflectionChildren {
6369
public func subst(with substitutionMap: SubstitutionMap) -> CanonicalType {
6470
return type.subst(with: substitutionMap).canonical
6571
}
72+
73+
public var canBeClass: TraitResult { bridged.canBeClass().result }
74+
}
75+
76+
public struct TypeArray : RandomAccessCollection, CustomReflectable {
77+
public let bridged: BridgedASTTypeArray
78+
79+
public var startIndex: Int { return 0 }
80+
public var endIndex: Int { return bridged.getCount() }
81+
82+
public init(bridged: BridgedASTTypeArray) {
83+
self.bridged = bridged
84+
}
85+
86+
public subscript(_ index: Int) -> Type {
87+
Type(bridged: bridged.getAt(index))
88+
}
89+
90+
public var customMirror: Mirror {
91+
let c: [Mirror.Child] = map { (label: nil, value: $0) }
92+
return Mirror(self, children: c)
93+
}
94+
}
95+
96+
extension BridgedCanType.TraitResult {
97+
var result: CanonicalType.TraitResult {
98+
switch self {
99+
case .IsNot: return .isNot
100+
case .CanBe: return .canBe
101+
case .Is: return .is
102+
default:
103+
fatalError("wrong type TraitResult enum case")
104+
}
105+
}
66106
}

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ private enum ImmutableScope {
648648
self = .borrow(singleBorrowIntroducer)
649649
case .functionArgument:
650650
self = .wholeFunction
651-
case .beginApply:
651+
case .beginApply, .uncheckOwnershipConversion:
652652
return nil
653653
}
654654
}

SwiftCompilerSources/Sources/Optimizer/DataStructures/Worklist.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ typealias ValueWorklist = Worklist<ValueSet>
7979
typealias OperandWorklist = Worklist<OperandSet>
8080

8181
extension InstructionWorklist {
82-
mutating func pushPredecessors(of inst: Instruction, ignoring ignoreInst: SingleValueInstruction) {
82+
mutating func pushPredecessors(of inst: Instruction, ignoring ignoreInst: Instruction) {
8383
if let prev = inst.previous {
8484
if prev != ignoreInst {
8585
pushIfNotVisited(prev)

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/AllocVectorLowering.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ private func createOutlinedGlobal(
224224
return
225225
}
226226

227-
let elementType = allocVectorBuiltin.substitutionMap.replacementTypes[0]!
227+
let function = allocVectorBuiltin.parentFunction
228+
let elementType = allocVectorBuiltin.substitutionMap.replacementTypes[0].loweredType(in: function)
228229
let outlinedGlobal = context.createGlobalVariable(
229-
name: context.mangleOutlinedVariable(from: allocVectorBuiltin.parentFunction),
230+
name: context.mangleOutlinedVariable(from: function),
230231
type: elementType, linkage: .private, isLet: false)
231232

232233
let globalBuilder = Builder(staticInitializerOf: outlinedGlobal, context)
@@ -249,8 +250,7 @@ private func createOutlinedGlobal(
249250
let globalAddr = builder.createGlobalAddr(global: outlinedGlobal, dependencyToken: nil)
250251
let rawVectorPointer = builder.createAddressToPointer(address: globalAddr, pointerType: allocVectorBuiltin.type,
251252
needStackProtection: false)
252-
allocVectorBuiltin.uses.replaceAll(with: rawVectorPointer, context)
253-
context.erase(instruction: allocVectorBuiltin)
253+
allocVectorBuiltin.replace(with: rawVectorPointer, context)
254254
}
255255

256256
private func createStackAllocatedVector(
@@ -259,13 +259,13 @@ private func createStackAllocatedVector(
259259
_ context: FunctionPassContext
260260
) {
261261
let builder = Builder(before: allocVectorBuiltin, context)
262-
let elementType = allocVectorBuiltin.substitutionMap.replacementTypes[0]!
262+
let function = allocVectorBuiltin.parentFunction
263+
let elementType = allocVectorBuiltin.substitutionMap.replacementTypes[0].loweredType(in: function)
263264
let allocVec = builder.createAllocVector(capacity: allocVectorBuiltin.operands[1].value, elementType: elementType)
264265
let rawVectorPointer = builder.createAddressToPointer(address: allocVec, pointerType: allocVectorBuiltin.type,
265266
needStackProtection: true)
266267

267-
allocVectorBuiltin.uses.replaceAll(with: rawVectorPointer, context)
268-
context.erase(instruction: allocVectorBuiltin)
268+
allocVectorBuiltin.replace(with: rawVectorPointer, context)
269269

270270
for endInst in liverange.ends {
271271
let builder = Builder(after: endInst, context)

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ClosureSpecialization.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ private func rewriteApplyInstruction(using specializedCallee: Function, callSite
301301
}
302302
}
303303

304-
oldApply.uses.replaceAll(with: newApply, context)
305-
context.erase(instruction: oldApply)
304+
oldApply.replace(with: newApply, context)
306305
}
307306

308307
// ===================== Utility functions and extensions ===================== //
@@ -1381,4 +1380,4 @@ let rewrittenCallerBodyTest = FunctionTest("closure_specialize_rewritten_caller_
13811380
print("Rewritten caller body for: \(function.name):")
13821381
print("\(function)\n")
13831382
}
1384-
}
1383+
}

0 commit comments

Comments
 (0)