Skip to content

Commit 8f6671c

Browse files
committed
Merge branch 'main' of github.com:apple/swift into HEAD
2 parents f8b02ef + 68a7a94 commit 8f6671c

File tree

458 files changed

+22348
-16846
lines changed

Some content is hidden

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

458 files changed

+22348
-16846
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
> **Note**\
44
> This is in reverse chronological order, so newer entries are added to the top.
55
6+
## Swift 5.9.2
7+
8+
* [SE-0407][]:
9+
10+
Member macros can specify a list of protocols via the `conformances` argument to the macro role. The macro implementation will be provided with those protocols that are listed but have not already been implemented by the type to which the member macro is attached, in the same manner as extension macros.
11+
12+
```swift
13+
@attached(member, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
14+
@attached(extension, conformances: Decodable, Encodable, names: named(init(from:), encode(to:)))
15+
macro Codable() = #externalMacro(module: "MyMacros", type: "CodableMacro")
16+
```
17+
618
## Swift 5.9
719

820
* [SE-0382][], [SE-0389][], [SE-0394][], [SE-0397][]:
@@ -9833,6 +9845,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
98339845
[SE-0389]: https://github.com/apple/swift-evolution/blob/main/proposals/0389-attached-macros.md
98349846
[SE-0394]: https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md
98359847
[SE-0397]: https://github.com/apple/swift-evolution/blob/main/proposals/0397-freestanding-declaration-macros.md
9848+
[SE-0407]: https://github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
98369849
[#64927]: <https://github.com/apple/swift/issues/64927>
98379850
[#42697]: <https://github.com/apple/swift/issues/42697>
98389851
[#42728]: <https://github.com/apple/swift/issues/42728>

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyBranch.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ private extension BranchInst {
7070
}
7171
parentBB.moveAllInstructions(toBeginOf: targetBB, context)
7272
parentBB.moveAllArguments(to: targetBB, context)
73+
context.erase(block: parentBB)
7374
} else {
7475
targetBB.moveAllInstructions(toEndOf: parentBB, context)
76+
context.erase(block: targetBB)
7577
}
7678
}
7779
}

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ let mandatoryPerformanceOptimizations = ModulePass(name: "mandatory-performance-
3030
(moduleContext: ModulePassContext) in
3131

3232
var worklist = FunctionWorklist()
33-
worklist.addAllPerformanceAnnotatedFunctions(of: moduleContext)
34-
worklist.addAllAnnotatedGlobalInitOnceFunctions(of: moduleContext)
33+
// For embedded Swift, optimize all the functions (there cannot be any
34+
// generics, type metadata, etc.)
35+
if moduleContext.options.enableEmbeddedSwift {
36+
worklist.addAllNonGenericFunctions(of: moduleContext)
37+
} else {
38+
worklist.addAllPerformanceAnnotatedFunctions(of: moduleContext)
39+
worklist.addAllAnnotatedGlobalInitOnceFunctions(of: moduleContext)
40+
}
3541

3642
optimizeFunctionsTopDown(using: &worklist, moduleContext)
3743
}
@@ -305,6 +311,13 @@ fileprivate struct FunctionWorklist {
305311
}
306312
}
307313

314+
mutating func addAllNonGenericFunctions(of moduleContext: ModulePassContext) {
315+
for f in moduleContext.functions where !f.isGenericFunction {
316+
pushIfNotVisited(f)
317+
}
318+
return
319+
}
320+
308321
mutating func addAllAnnotatedGlobalInitOnceFunctions(of moduleContext: ModulePassContext) {
309322
for f in moduleContext.functions where f.isGlobalInitOnceFunction {
310323
if let global = f.getInitializedGlobal(),

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ extension MutatingContext {
7171
erase(instruction: inst)
7272
}
7373

74+
func erase(block: BasicBlock) {
75+
_bridged.eraseBlock(block.bridged)
76+
}
77+
7478
func tryOptimizeApplyOfPartialApply(closure: PartialApplyInst) -> Bool {
7579
if _bridged.tryOptimizeApplyOfPartialApply(closure.bridged) {
7680
notifyInstructionsChanged()
@@ -227,10 +231,6 @@ struct FunctionPassContext : MutatingContext {
227231
}
228232
}
229233

230-
func erase(block: BasicBlock) {
231-
_bridged.eraseBlock(block.bridged)
232-
}
233-
234234
func modifyEffects(in function: Function, _ body: (inout FunctionEffects) -> ()) {
235235
notifyEffectsChanged()
236236
function._modifyEffects(body)

SwiftCompilerSources/Sources/Optimizer/PassManager/Options.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ struct Options {
2828
_bridged.enableSimplificationFor(inst.bridged)
2929
}
3030

31+
var enableEmbeddedSwift: Bool {
32+
_bridged.enableEmbeddedSwift()
33+
}
34+
3135
enum AssertConfiguration {
3236
case enabled
3337
case disabled

SwiftCompilerSources/Sources/SIL/Function.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ final public class Function : CustomStringConvertible, HasShortDescription, Hash
137137
/// It's called from a `[global_init]` function via a `builtin "once"`.
138138
public var isGlobalInitOnceFunction: Bool { bridged.isGlobalInitOnceFunction() }
139139

140+
public var isGenericFunction: Bool { bridged.isGenericFunction() }
141+
140142
/// Kinds of effect attributes which can be defined for a Swift function.
141143
public enum EffectAttribute {
142144
/// No effect attribute is specified.

cmake/modules/AddPureSwift.cmake

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ function(add_pure_swift_host_tool name)
269269

270270
# Option handling
271271
set(options)
272-
set(single_parameter_options)
272+
set(single_parameter_options
273+
SWIFT_COMPONENT)
273274
set(multiple_parameter_options
274275
DEPENDENCIES
275276
SWIFT_DEPENDENCIES)
@@ -341,6 +342,18 @@ function(add_pure_swift_host_tool name)
341342
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/${name}.swiftmodule"
342343
COMMAND_EXPAND_LISTS
343344
COMMENT "Update mtime of executable outputs workaround")
344-
# Export this target.
345-
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name})
345+
346+
if(NOT APSHT_SWIFT_COMPONENT STREQUAL no_component)
347+
add_dependencies(${APSHT_SWIFT_COMPONENT} ${name})
348+
swift_install_in_component(TARGETS ${name}
349+
COMPONENT ${APSHT_SWIFT_COMPONENT}
350+
RUNTIME DESTINATION bin)
351+
swift_is_installing_component(${APSHT_SWIFT_COMPONENT} is_installing)
352+
endif()
353+
354+
if(NOT is_installing)
355+
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name})
356+
else()
357+
set_property(GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${name})
358+
endif()
346359
endfunction()

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)
573573
else()
574574
message(FATAL_ERROR "Unknown BOOTSTRAPPING_MODE '${ASRLF_BOOTSTRAPPING_MODE}'")
575575
endif()
576+
else()
577+
target_link_directories(${target} PRIVATE
578+
${SWIFT_PATH_TO_SWIFT_SDK}/usr/lib/swift/${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}/${SWIFT_HOST_VARIANT_ARCH})
576579
endif()
577580
578581
if(SWIFT_SWIFT_PARSER)

cmake/modules/AddSwiftUnittests.cmake

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,31 @@ function(add_swift_unittest test_dirname)
111111
endif()
112112
endif()
113113

114+
file(RELATIVE_PATH relative_lib_path "${CMAKE_CURRENT_BINARY_DIR}" "${SWIFT_LIBRARY_OUTPUT_INTDIR}")
115+
116+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
117+
set_property(
118+
TARGET ${test_dirname}
119+
APPEND PROPERTY INSTALL_RPATH "@executable_path/${relative_lib_path}")
120+
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
121+
set_property(
122+
TARGET ${test_dirname}
123+
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${relative_lib_path}")
124+
endif()
125+
114126
if (SWIFT_SWIFT_PARSER AND NOT ASU_IS_TARGET_TEST)
115127
# Link to stdlib the compiler uses.
116-
_add_swift_runtime_link_flags(${test_dirname} "../../lib" "")
117-
set_property(TARGET ${test_dirname} PROPERTY BUILD_WITH_INSTALL_RPATH OFF)
128+
_add_swift_runtime_link_flags(${test_dirname} "${relative_lib_path}" "")
129+
130+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
131+
set_property(
132+
TARGET ${test_dirname}
133+
APPEND PROPERTY INSTALL_RPATH "@executable_path/${relative_lib_path}/swift/host")
134+
elseif(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
135+
set_property(
136+
TARGET ${test_dirname}
137+
APPEND PROPERTY INSTALL_RPATH "$ORIGIN/${relative_lib_path}/swift/host")
138+
endif()
118139
endif()
119140
endfunction()
120141

cmake/modules/SwiftImplicitImport.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ function(swift_supports_implicit_module module_name out_var)
33
file(WRITE "${CMAKE_BINARY_DIR}/tmp/empty-check-${module_name}.swift" "")
44
execute_process(
55
COMMAND
6+
${CMAKE_COMMAND}
7+
-E env --unset=SWIFT_LOADED_MODULE_TRACE_FILE
68
"${CMAKE_Swift_COMPILER}"
79
-Xfrontend -disable-implicit-${module_name}-module-import
810
-Xfrontend -parse-stdlib

0 commit comments

Comments
 (0)