Skip to content

Commit 16d3b33

Browse files
authored
Merge pull request #1162 from swiftwasm/maxd/master-merge
Fix build issues after merging master
2 parents b31862a + 501e4cb commit 16d3b33

File tree

372 files changed

+5797
-1891
lines changed

Some content is hidden

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

372 files changed

+5797
-1891
lines changed

benchmark/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ set(SWIFT_BENCH_MODULES
108108
single-source/LuhnAlgoLazy
109109
single-source/MapReduce
110110
single-source/Memset
111+
single-source/Mirror
111112
single-source/MonteCarloE
112113
single-source/MonteCarloPi
113114
single-source/NSDictionaryCastToSwift

benchmark/single-source/Mirror.swift

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//===--- Mirror.swift ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// This test measures performance of Mirror and related things.
14+
import TestsUtils
15+
16+
public let TypeName = BenchmarkInfo(
17+
name: "TypeName",
18+
runFunction: run_TypeName,
19+
tags: [.api, .String])
20+
21+
public let MirrorDefault = BenchmarkInfo(
22+
name: "MirrorDefault",
23+
runFunction: run_MirrorDefault,
24+
tags: [.api, .String])
25+
26+
struct S1 { var s: String; var d: Double }
27+
struct S2 { var i: Int; var a: [Range<Int>] }
28+
29+
class C { var i: Int = 0 }
30+
class D: C { var s: String = "" }
31+
32+
enum E {
33+
case a,b(Int)
34+
}
35+
36+
struct G<T> { var t: T }
37+
class H<T>: C { var t: T; init(_ t: T) { self.t = t }}
38+
39+
public func run_MirrorDefault(scale: Int) {
40+
let N = 100*scale
41+
42+
let s1 = S1(s: "foo", d: 3.14)
43+
let s2 = S2(i: 42, a: [0..<4])
44+
let c = C()
45+
let d = D()
46+
let e = E.a
47+
let f = E.b(99)
48+
let g = G(t: 12.3)
49+
let h = H<[Int]>([1,2,3])
50+
51+
var str = ""
52+
53+
for _ in 0..<N {
54+
str = "\(s1),\(s2),\(c),\(d),\(e),\(f),\(g),\(h)"
55+
blackHole(str)
56+
}
57+
58+
CheckResults(str ==
59+
"S1(s: \"foo\", d: 3.14),S2(i: 42, a: [Range(0..<4)]),Mirror.C,Mirror.D,a,b(99),G<Double>(t: 12.3),Mirror.H<Swift.Array<Swift.Int>>")
60+
}
61+
62+
func typename<T>(of: T.Type) -> String {
63+
"\(T.self)"
64+
}
65+
66+
public func run_TypeName(scale: Int) {
67+
let N = 1_000*scale
68+
var a: [String] = []
69+
a.reserveCapacity(16)
70+
71+
for _ in 0..<N {
72+
a = []
73+
a.removeAll(keepingCapacity: true)
74+
a.append(typename(of: S1.self))
75+
a.append(typename(of: S2.self))
76+
a.append(typename(of: C.self))
77+
a.append(typename(of: D.self))
78+
a.append(typename(of: G<S1>.self))
79+
a.append(typename(of: G<C>.self))
80+
a.append(typename(of: G<String>.self))
81+
a.append(typename(of: H<Int>.self))
82+
a.append(typename(of: [S1].self))
83+
a.append(typename(of: [G<Int>].self))
84+
a.append(typename(of: [H<S1>].self))
85+
a.append(typename(of: S1?.self))
86+
a.append(typename(of: C?.self))
87+
blackHole(a)
88+
}
89+
90+
let expected = ["S1",
91+
"S2",
92+
"C",
93+
"D",
94+
"G<S1>",
95+
"G<C>",
96+
"G<String>",
97+
"H<Int>",
98+
"Array<S1>",
99+
"Array<G<Int>>",
100+
"Array<H<S1>>",
101+
"Optional<S1>",
102+
"Optional<C>",
103+
]
104+
CheckResults(a == expected)
105+
}

benchmark/utils/main.swift

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ import LuhnAlgoEager
9696
import LuhnAlgoLazy
9797
import MapReduce
9898
import Memset
99+
import Mirror
99100
import MonteCarloE
100101
import MonteCarloPi
101102
import NibbleSort
@@ -281,6 +282,7 @@ registerBenchmark(LuhnAlgoEager)
281282
registerBenchmark(LuhnAlgoLazy)
282283
registerBenchmark(MapReduce)
283284
registerBenchmark(Memset)
285+
registerBenchmark(MirrorDefault)
284286
registerBenchmark(MonteCarloE)
285287
registerBenchmark(MonteCarloPi)
286288
registerBenchmark(NSDictionaryCastToSwift)
@@ -366,6 +368,7 @@ registerBenchmark(Suffix)
366368
registerBenchmark(SuperChars)
367369
registerBenchmark(TwoSum)
368370
registerBenchmark(TypeFlood)
371+
registerBenchmark(TypeName)
369372
registerBenchmark(UTF8Decode)
370373
registerBenchmark(Walsh)
371374
registerBenchmark(WordCount)

cmake/modules/AddSwift.cmake

+7-26
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,10 @@ function(_set_target_prefix_and_suffix target kind sdk)
7575
endif()
7676
endfunction()
7777

78-
function(is_darwin_based_sdk sdk_name out_var)
79-
if ("${sdk_name}" STREQUAL "OSX" OR
80-
"${sdk_name}" STREQUAL "IOS" OR
81-
"${sdk_name}" STREQUAL "IOS_SIMULATOR" OR
82-
"${sdk_name}" STREQUAL "TVOS" OR
83-
"${sdk_name}" STREQUAL "TVOS_SIMULATOR" OR
84-
"${sdk_name}" STREQUAL "WATCHOS" OR
85-
"${sdk_name}" STREQUAL "WATCHOS_SIMULATOR")
86-
set(${out_var} TRUE PARENT_SCOPE)
87-
else()
88-
set(${out_var} FALSE PARENT_SCOPE)
89-
endif()
90-
endfunction()
91-
9278
# Usage:
9379
# _add_host_variant_c_compile_link_flags(name)
9480
function(_add_host_variant_c_compile_link_flags name)
95-
is_darwin_based_sdk("${SWIFT_HOST_VARIANT_SDK}" IS_DARWIN)
96-
if(IS_DARWIN)
81+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
9782
set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
9883
endif()
9984

@@ -107,7 +92,7 @@ function(_add_host_variant_c_compile_link_flags name)
10792

10893
set(_sysroot
10994
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
110-
if(IS_DARWIN)
95+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
11196
target_compile_options(${name} PRIVATE -isysroot;${_sysroot})
11297
elseif(NOT SWIFT_COMPILER_IS_MSVC_LIKE AND NOT "${_sysroot}" STREQUAL "/")
11398
target_compile_options(${name} PRIVATE --sysroot=${_sysroot})
@@ -122,7 +107,7 @@ function(_add_host_variant_c_compile_link_flags name)
122107
endif()
123108
endif()
124109

125-
if(IS_DARWIN)
110+
if(SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
126111
# We collate -F with the framework path to avoid unwanted deduplication
127112
# of options by target_compile_options -- this way no undesired
128113
# side effects are introduced should a new search path be added.
@@ -548,14 +533,10 @@ function(add_swift_host_library name)
548533
"LINKER:-current_version,${SWIFT_COMPILER_VERSION}")
549534
endif()
550535

551-
set(DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
552-
# MSVC, clang-cl, gcc don't understand -target.
553-
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT SWIFT_COMPILER_IS_MSVC_LIKE)
554-
get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}"
555-
MACCATALYST_BUILD_FLAVOR ""
556-
DEPLOYMENT_VERSION "${DEPLOYMENT_VERSION}")
557-
target_link_options(${name} PRIVATE -target;${target})
558-
endif()
536+
get_target_triple(target target_variant "${SWIFT_HOST_VARIANT_SDK}" "${SWIFT_HOST_VARIANT_ARCH}"
537+
MACCATALYST_BUILD_FLAVOR ""
538+
DEPLOYMENT_VERSION "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_DEPLOYMENT_VERSION}")
539+
target_link_options(${name} PRIVATE -target;${target})
559540
endif()
560541

561542
add_dependencies(dev ${name})

docs/Branches.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,22 @@ You can use any of the branch names as the argument to `--scheme`, such as `mast
5858

5959
- LLVM Project: the destination branch depends on the kind of change that must be made:
6060

61-
1) LLVM Project changes that don't depend on Swift: New commits go to `master` in the upstream [llvm-project](https://github.com/llvm/llvm-project).
61+
1) LLVM Project changes that don't depend on Swift
62+
63+
- New commits go to `master` in the upstream [llvm-project](https://github.com/llvm/llvm-project).
6264

63-
... then these commits can be cherry-picked to an appropriate, `swift/master` aligned `apple/stable/*` branch in Apple's fork of [llvm-project](https://github.com/apple/llvm-project). Please see
64-
[Apple's branching scheme](https://github.com/apple/llvm-project/blob/apple/master/apple-docs/AppleBranchingScheme.md)
65-
document to determine which `apple/stable/*` branch you should cherry-pick to.
65+
- Then cherry-pick these commits to an appropriate, `swift/master` aligned `apple/stable/*` branch in Apple's fork of [llvm-project](https://github.com/apple/llvm-project). Please see [Apple's branching scheme](https://github.com/apple/llvm-project/blob/apple/master/apple-docs/AppleBranchingScheme.md) document to determine which `apple/stable/*` branch you should cherry-pick to.
66+
67+
Note that **no new changes should be submitted directly to `apple/master`**. We are actively working on eliminating the differences from upstream LLVM.
6668

67-
2) Changes that depend on Swift (this only applies to LLDB): new commits go to `swift/master-next`
69+
2) Changes that depend on Swift (this only applies to LLDB)
70+
- New commits go to `swift/master` (_not_ an `apple/stable/*` branch, as these shouldn't contain changes that depend on Swift).
6871

69-
...then cherry-pick to the release branch (`swift/swift-x.y-branch`) if necessary, following the appropriate release process. (Usually this means filling out a standard template, finding someone to review your code if that hasn't already happened, and getting approval from that repo's *release manager.)*
72+
- Then cherry-pick these commits to `swift/master-next`.
73+
74+
- If necessary, cherry-pick to the release branch (`swift/release/x.y`), following the appropriate release process. (Usually this means filling out a standard template, finding someone to review your code if that hasn't already happened, and getting approval from that repo's *release manager.)*
75+
76+
In the long term we want to eliminate the differences from upstream LLVM for these changes as well, but for now there is no concrete plan. So, submitting to `swift/master-next` continues to be allowed.
7077

7178
## Automerging
7279

docs/DebuggingTheCompiler.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ Here is how to dump the IR after the main phases of the Swift compiler
6464

6565
* **Parser** To print the AST after parsing:
6666

67-
```bash
67+
```sh
6868
swiftc -dump-ast -O file.swift
6969
```
7070

7171
* **SILGen** To print the SIL immediately after SILGen:
7272

73-
```bash
73+
```sh
7474
swiftc -emit-silgen -O file.swift
7575
```
7676

7777
* **Mandatory SIL passes** To print the SIL after the mandatory passes:
7878

79-
```bash
79+
```sh
8080
swiftc -emit-sil -Onone file.swift
8181
```
8282

@@ -87,25 +87,25 @@ swiftc -emit-sil -Onone file.swift
8787
* **Performance SIL passes** To print the SIL after the complete SIL
8888
optimization pipeline:
8989

90-
```bash
90+
```sh
9191
swiftc -emit-sil -O file.swift
9292
```
9393

9494
* **IRGen** To print the LLVM IR after IR generation:
9595

96-
```bash
96+
```sh
9797
swiftc -emit-ir -Xfrontend -disable-llvm-optzns -O file.swift
9898
```
9999

100100
* **LLVM passes** To print the LLVM IR after LLVM passes:
101101

102-
```bash
102+
```sh
103103
swiftc -emit-ir -O file.swift
104104
```
105105

106106
* **Code generation** To print the final generated code:
107107

108-
```bash
108+
```sh
109109
swiftc -S -O file.swift
110110
```
111111

0 commit comments

Comments
 (0)