Skip to content

Commit 5b39ba6

Browse files
authored
Merge branch 'main' into swift-lexical-lookup-validation
2 parents bda3c7f + 4f32598 commit 5b39ba6

File tree

152 files changed

+1757
-1083
lines changed

Some content is hidden

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

152 files changed

+1757
-1083
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,10 @@ if(SWIFT_ENABLE_DISPATCH)
14711471
endif()
14721472

14731473
# Add all of the subdirectories, where we actually do work.
1474+
add_subdirectory(include)
1475+
if(SWIFT_INCLUDE_TOOLS)
1476+
add_subdirectory(lib)
1477+
endif()
14741478

14751479
###############
14761480
# PLEASE READ #
@@ -1523,11 +1527,7 @@ if(SWIFT_INCLUDE_APINOTES)
15231527
add_subdirectory(apinotes)
15241528
endif()
15251529

1526-
add_subdirectory(include)
1527-
15281530
if(SWIFT_INCLUDE_TOOLS)
1529-
add_subdirectory(lib)
1530-
15311531
add_subdirectory(SwiftCompilerSources)
15321532

15331533
# Always include this after including stdlib/!

Runtimes/Core/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ add_compile_definitions(
118118
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>>
119119
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>)
120120

121-
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>)
121+
add_compile_options(
122+
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
123+
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
124+
$<$<COMPILE_LANGUAGE:CXX>:-funwind-tables>
125+
$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>)
122126

123127
include_directories(include)
124128

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/RedundantLoadElimination.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,14 @@ private struct InstructionScanner {
480480

481481
private mutating func visit(instruction: Instruction) -> ScanResult {
482482
switch instruction {
483-
case is FixLifetimeInst, is EndAccessInst, is BeginBorrowInst, is EndBorrowInst:
484-
return .transparent
485-
483+
case is FixLifetimeInst, is EndAccessInst, is EndBorrowInst:
484+
// Those scope-ending instructions are only irrelevant if the preceding load is not changed.
485+
// If it is changed from `load [copy]` -> `load [take]` the memory effects of those scope-ending
486+
// instructions prevent that the `load [take]` will illegally mutate memory which is protected
487+
// from mutation by the scope.
488+
if load.loadOwnership != .take {
489+
return .transparent
490+
}
486491
case let precedingLoad as LoadInst:
487492
if precedingLoad == load {
488493
// We need to stop the data flow analysis when we visit the original load again.

SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyUncheckedEnumData.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import SIL
1414

15-
extension UncheckedEnumDataInst : OnoneSimplifyable {
15+
extension UncheckedEnumDataInst : OnoneSimplifyable, SILCombineSimplifyable {
1616
func simplify(_ context: SimplifyContext) {
1717
guard let enumInst = self.enum as? EnumInst else {
1818
return

SwiftCompilerSources/Sources/Optimizer/PassManager/PassRegistration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ private func registerSwiftPasses() {
113113
registerForSILCombine(DestructureTupleInst.self, { run(DestructureTupleInst.self, $0) })
114114
registerForSILCombine(TypeValueInst.self, { run(TypeValueInst.self, $0) })
115115
registerForSILCombine(ClassifyBridgeObjectInst.self, { run(ClassifyBridgeObjectInst.self, $0) })
116+
registerForSILCombine(UncheckedEnumDataInst.self, { run(UncheckedEnumDataInst.self, $0) })
116117

117118
// Test passes
118119
registerPass(aliasInfoDumper, { aliasInfoDumper.run($0) })

SwiftCompilerSources/Sources/Optimizer/Utilities/OptUtils.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,9 +576,18 @@ extension SimplifyContext {
576576
let singleUse = preserveDebugInfo ? first.uses.singleUse : first.uses.ignoreDebugUses.singleUse
577577
let canEraseFirst = singleUse?.instruction == second
578578

579-
if !canEraseFirst && first.parentFunction.hasOwnership && replacement.ownership == .owned {
580-
// We cannot add more uses to `replacement` without inserting a copy.
581-
return
579+
if !canEraseFirst && first.parentFunction.hasOwnership {
580+
if replacement.ownership == .owned {
581+
// We cannot add more uses to `replacement` without inserting a copy.
582+
return
583+
}
584+
if first.ownership == .owned {
585+
// We have to insert a compensating destroy because we are deleting the second instruction but
586+
// not the first one. This can happen if the first instruction is an `enum` which constructs a
587+
// non-trivial enum from a trivial payload.
588+
let builder = Builder(before: second, self)
589+
builder.createDestroyValue(operand: first)
590+
}
582591
}
583592

584593
second.uses.replaceAll(with: replacement, self)

benchmark/utils/ObjectiveCTests/ObjectiveCTests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
2323
NSArray<NSString *> *bridgedStrings;
2424
}
2525

26-
- (id)init;
26+
- (instancetype)init NS_DESIGNATED_INITIALIZER;
2727
- (void)setUpStringTests:(NSArray<NSString *> *)bridgedStrings;
2828
- (void)testFromString:(NSString *) str;
2929
- (NSString *)testToString;

benchmark/utils/ObjectiveCTests/ObjectiveCTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ - (const unichar *)_fastCharacterContents {
102102

103103
@implementation BridgeTester
104104

105-
- (id)init {
105+
- (instancetype)init {
106106
self = [super init];
107107
if (!self)
108108
return self;

docs/Android.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To follow along with this guide, you'll need:
3636
instructions in the Swift project README.
3737
2. The latest build of the Swift compiler for your Linux distro, available at
3838
https://www.swift.org/download/ or sometimes your distro package manager.
39-
3. The latest version of the Android LTS NDK (r26d at the time of this writing),
39+
3. The latest version of the Android LTS NDK (r27c at the time of this writing),
4040
available to download here:
4141
https://developer.android.com/ndk/downloads
4242
4. An Android device with remote debugging enabled or the emulator. We require
@@ -54,9 +54,9 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
5454
have a Swift toolchain in your path):
5555

5656
```
57-
$ NDK_PATH=path/to/android-ndk-r26d
58-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
59-
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a
57+
$ NDK_PATH=path/to/android-ndk-r27c
58+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
59+
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a
6060
$ utils/build-script \
6161
-R \ # Build in ReleaseAssert mode.
6262
--android \ # Build for Android.
@@ -83,8 +83,8 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
8383
source file, targeting Android:
8484

8585
```
86-
$ NDK_PATH="path/to/android-ndk-r26d"
87-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-07-09-a-ubuntu22.04/usr/bin
86+
$ NDK_PATH="path/to/android-ndk-r27c"
87+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
8888
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8989
# The location of the tools used to build Android binaries
9090
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
@@ -122,18 +122,20 @@ commands to copy the Swift Android stdlib:
122122

123123
```
124124
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftCore.so /data/local/tmp
125-
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftGlibc.so /data/local/tmp
125+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftAndroid.so /data/local/tmp
126126
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftSwiftOnoneSupport.so /data/local/tmp
127127
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
128128
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_Concurrency.so /data/local/tmp
129+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_RegexParser.so /data/local/tmp
130+
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswift_StringProcessing.so /data/local/tmp
129131
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libdispatch.so /data/local/tmp
130132
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlocksRuntime.so /data/local/tmp
131133
```
132134

133135
In addition, you'll also need to copy the Android NDK's libc++:
134136

135137
```
136-
$ adb push /path/to/android-ndk-r26d/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
138+
$ adb push /path/to/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
137139
```
138140

139141
Finally, you'll need to copy the `hello` executable you built in the
@@ -176,7 +178,7 @@ $ utils/build-script \
176178
-R \ # Build in ReleaseAssert mode.
177179
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
178180
--android \ # Build for Android.
179-
--android-ndk ~/android-ndk-r26d \ # Path to an Android NDK.
181+
--android-ndk ~/android-ndk-r27c \ # Path to an Android NDK.
180182
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7 or x86_64
181183
--android-api-level 21
182184
```

docs/HowToGuides/GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ Now check if the version string has been updated (assumes you have `platform` sh
455455
defined as specified in the previous subsection:
456456

457457
```sh
458-
../build/Ninja-RelWithDebInfoAssert/swift-$(platform)-$(uname -m)/bin/swift-frontend --version
458+
../build/Ninja-RelWithDebInfoAssert/swift-${platform}-$(uname -m)/bin/swift-frontend --version
459459
```
460460

461461
This should print your updated version string.

0 commit comments

Comments
 (0)