Skip to content

Commit a526f73

Browse files
committed
Merge branch 'master' into hermetic
2 parents b91800d + cde899d commit a526f73

File tree

356 files changed

+8574
-3938
lines changed

Some content is hidden

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

356 files changed

+8574
-3938
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ docs/_build
4141
.vs
4242

4343
# clangd
44+
.cache
4445
.clangd
4546

4647
#==============================================================================#

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,8 @@ if(SWIFT_INCLUDE_TOOLS)
11131113
add_subdirectory(tools)
11141114
endif()
11151115

1116+
add_subdirectory(localization)
1117+
11161118
add_subdirectory(utils)
11171119

11181120
add_subdirectory(userdocs)

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
| **OS** | **Architecture** | **Build** |
1818
|---|:---:|:---:|
1919
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le)|
20-
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
21-
|**[Ubuntu 18.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_18.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-aarch64)|
20+
|**[Ubuntu 18.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_18.04_docker.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-ubuntu-18.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-ubuntu-18.04-aarch64)|
21+
|**[Ubuntu 20.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_20.04_docker.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-ubuntu-20.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-ubuntu-20.04-aarch64)|
22+
|**[CentOS 8 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_centos_8_docker.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-centos8-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-centos8-aarch64)|
23+
|**[Amazon Linux 2](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_amazon_linux_2_docker.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-amazon-linux-2-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-amazon-linux-2-aarch64)|
2224
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
2325
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|
2426
|**[Windows 2019 (VS 2017)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_windows_2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-windows-x86_64)|

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,17 @@ function (swift_benchmark_compile_archopts)
367367
"-F" "${sdk}/../../../Developer/Library/Frameworks"
368368
"-sdk" "${sdk}"
369369
"-no-link-objc-runtime")
370+
371+
# If we are not compiling at -Onone and are performing WMO, always emit
372+
# optimization-records.
373+
if(NOT ${optflag} STREQUAL "Onone" AND "${bench_flags}" MATCHES "-whole-module.*")
374+
list(APPEND common_options "-save-optimization-record=bitstream")
375+
endif()
370376
endif()
371377

372378
set(opt_view_main_dir)
373379
if(SWIFT_BENCHMARK_GENERATE_OPT_VIEW AND LLVM_HAVE_OPT_VIEWER_MODULES)
374380
if(NOT ${optflag} STREQUAL "Onone" AND "${bench_flags}" MATCHES "-whole-module.*")
375-
list(APPEND common_options "-save-optimization-record")
376381
set(opt_view_main_dir "${objdir}/opt-view")
377382
endif()
378383
endif()

benchmark/scripts/compare_perf_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ def compare(name):
551551

552552
comparisons = list(map(compare, comparable_tests))
553553

554-
def partition(l, p):
554+
def partition(items, p):
555555
return functools.reduce(
556-
lambda x, y: x[not p(y)].append(y) or x, l, ([], [])
556+
lambda x, y: x[not p(y)].append(y) or x, items, ([], [])
557557
)
558558

559559
decreased, not_decreased = partition(

benchmark/scripts/perf_test_driver/perf_test_driver.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
from __future__ import print_function
1616

1717
import functools
18+
import glob
1819
import multiprocessing
1920
import os
21+
import platform
2022
import re
2123
import subprocess
2224

@@ -80,6 +82,22 @@ def _unwrap_self(args):
8082
return type(args[0]).process_input(*args)
8183

8284

85+
def get_benchmark_executable(binary_dir, opt_level):
86+
suffix = opt_level + "-" + platform.machine() + "*"
87+
pattern = os.path.join(binary_dir, "Benchmark_" + suffix)
88+
executables = glob.glob(pattern)
89+
if len(executables) == 0:
90+
raise ValueError(
91+
"No benchmark executable for file name pattern " +
92+
pattern + " found")
93+
if len(executables) > 1:
94+
raise ValueError(
95+
"Multiple benchmark executables for file name pattern " +
96+
pattern + " found\n" +
97+
str(executables))
98+
return executables[0]
99+
100+
83101
BenchmarkDriver_OptLevels = ["Onone", "O", "Osize"]
84102

85103

@@ -92,7 +110,7 @@ def __init__(
92110
opt_levels=BenchmarkDriver_OptLevels,
93111
):
94112
self.targets = [
95-
(os.path.join(binary_dir, "Benchmark_%s" % o), o) for o in opt_levels
113+
(get_benchmark_executable(binary_dir, o), o) for o in opt_levels
96114
]
97115
self.xfail_list = xfail_list
98116
self.enable_parallel = enable_parallel
@@ -112,8 +130,8 @@ def run_for_opt_level(self, binary, opt_level, test_filter):
112130
print("testing driver at path: %s" % binary)
113131
names = []
114132
output = subprocess.check_output([binary, "--list"], universal_newlines=True)
115-
for l in output.split("\n")[1:]:
116-
m = BENCHMARK_OUTPUT_RE.match(l)
133+
for line in output.split("\n")[1:]:
134+
m = BENCHMARK_OUTPUT_RE.match(line)
117135
if m is None:
118136
continue
119137
names.append(m.group(1))

benchmark/single-source/DropFirst.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Sequences = [
3838
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3939
('Array', 'array'),
4040
]
41-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
41+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4242

4343
Sequences = Sequences + map(lazy, Sequences)
4444
}%

benchmark/single-source/DropLast.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Sequences = [
3838
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3939
('Array', 'array'),
4040
]
41-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
41+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4242

4343
Sequences = Sequences + map(lazy, Sequences)
4444
}%

benchmark/single-source/DropWhile.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Sequences = [
3838
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3939
('Array', 'array'),
4040
]
41-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
41+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4242

4343
Sequences = Sequences + map(lazy, Sequences)
4444
}%

benchmark/single-source/Prefix.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Sequences = [
3737
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3838
('Array', 'array'),
3939
]
40-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
40+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4141

4242
Sequences = Sequences + map(lazy, Sequences)
4343
}%

benchmark/single-source/PrefixWhile.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Sequences = [
3737
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3838
('Array', 'array'),
3939
]
40-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
40+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4141

4242
Sequences = Sequences + map(lazy, Sequences)
4343
}%

benchmark/single-source/Suffix.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Sequences = [
3737
('AnyCollection', 'AnyCollection(0..<sequenceCount)'),
3838
('Array', 'array'),
3939
]
40-
def lazy ((Name, Expr)) : return (Name + 'Lazy', '(' + Expr + ').lazy')
40+
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')
4141

4242
Sequences = Sequences + map(lazy, Sequences)
4343
}%

cmake/caches/Windows-x86_64.cmake

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
set(LLVM_ENABLE_PROJECTS
2+
clang
3+
clang-tools-extra
4+
lld
5+
lldb
6+
CACHE STRING "")
7+
8+
set(LLVM_EXTERNAL_PROJECTS
9+
cmark
10+
swift
11+
CACHE STRING "")
12+
13+
# NOTE(compnerd) always enable assertions, the toolchain will not provide enough
14+
# context to resolve issues otherwise and may silently generate invalid output.
15+
set(LLVM_ENABLE_ASSERTIONS YES CACHE BOOL "")
16+
17+
set(ENABLE_X86_RELAX_RELOCATIONS YES CACHE BOOL "")
18+
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
19+
set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "")
20+
21+
# Disable certain targets to reduce the configure time or to avoid configuration
22+
# differences (and in some cases weird build errors on a complete build).
23+
set(LLVM_APPEND_VC_REV NO CACHE BOOL "")
24+
set(LLVM_BUILD_LLVM_DYLIB NO CACHE BOOL "")
25+
set(LLVM_BUILD_LLVM_C_DYLIB NO CACHE BOOL "")
26+
set(LLVM_ENABLE_LIBEDIT NO CACHE BOOL "")
27+
set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "")
28+
set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "")
29+
set(LLVM_ENABLE_ZLIB NO CACHE BOOL "")
30+
set(LLVM_INCLUDE_BENCHMARKS NO CACHE BOOL "")
31+
set(LLVM_INCLUDE_DOCS NO CACHE BOOL "")
32+
set(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "")
33+
set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "")
34+
set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "")
35+
set(LLVM_TOOL_LLVM_SHLIB_BUILD NO CACHE BOOL "")
36+
37+
# Avoid swig dependency for lldb
38+
set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "")
39+
set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "")
40+
41+
# This requires perl which may not be available on Windows
42+
set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "")
43+
set(SWIFT_BUILD_STATIC_STDLIB NO CACHE BOOL "")
44+
set(SWIFT_BUILD_STATIC_SDK_OVERLAY NO CACHE BOOL "")
45+
46+
set(LLVM_INSTALL_BINUTILS_SYMLINKS YES CACHE BOOL "")
47+
set(LLVM_INSTALL_TOOLCHAIN_ONLY YES CACHE BOOL "")
48+
set(LLVM_TOOLCHAIN_TOOLS
49+
addr2line
50+
ar
51+
c++filt
52+
dsymutil
53+
dwp
54+
# lipo
55+
llvm-ar
56+
llvm-cov
57+
llvm-cvtres
58+
llvm-cxxfilt
59+
llvm-dlltool
60+
llvm-dwarfdump
61+
llvm-dwp
62+
llvm-lib
63+
llvm-lipo
64+
llvm-mt
65+
llvm-mt
66+
llvm-nm
67+
llvm-objcopy
68+
llvm-objdump
69+
llvm-pdbutil
70+
llvm-profdata
71+
llvm-ranlib
72+
llvm-rc
73+
llvm-readelf
74+
llvm-readobj
75+
llvm-size
76+
llvm-strings
77+
llvm-strip
78+
llvm-symbolizer
79+
llvm-undname
80+
nm
81+
objcopy
82+
objdump
83+
ranlib
84+
readelf
85+
size
86+
strings
87+
CACHE STRING "")
88+
89+
set(CLANG_TOOLS
90+
clang
91+
clangd
92+
clang-format
93+
clang-resource-headers
94+
clang-tidy
95+
CACHE STRING "")
96+
97+
set(LLD_TOOLS
98+
lld
99+
CACHE STRING "")
100+
101+
set(LLDB_TOOLS
102+
liblldb
103+
lldb
104+
lldb-argdumper
105+
lldb-python-scripts
106+
lldb-server
107+
lldb-vscode
108+
repl_swift
109+
CACHE STRING "")
110+
111+
set(SWIFT_INSTALL_COMPONENTS
112+
autolink-driver
113+
compiler
114+
clang-builtin-headers
115+
editor-integration
116+
tools
117+
sourcekit-inproc
118+
swift-remote-mirror
119+
swift-remote-mirror-headers
120+
CACHE STRING "")
121+
122+
set(LLVM_DISTRIBUTION_COMPONENTS
123+
IndexStore
124+
libclang
125+
libclang-headers
126+
LTO
127+
${LLVM_TOOLCHAIN_TOOLS}
128+
${CLANG_TOOLS}
129+
${LLD_TOOLS}
130+
${LLDB_TOOLS}
131+
${SWIFT_INSTALL_COMPONENTS}
132+
CACHE STRING "")

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ Globals
171171
global ::= entity 'Wvd' // field offset
172172
global ::= entity 'WC' // resilient enum tag index
173173

174+
global ::= global 'MK' // instantiation cache associated with global
175+
174176
A direct symbol resolves directly to the address of an object. An
175177
indirect symbol resolves to the address of a pointer to the object.
176178
They are distinct manglings to make a certain class of bugs

docs/CompilerPerformance.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -559,30 +559,6 @@ compilers on hand while you're working.
559559
0.0001 (100.0%) 0.0001 (100.0%) 0.0001 (100.0%) 0.0490 (100.0%) Total
560560
```
561561
562-
- `-Xfrontend -debug-time-compilation`: asks each frontend to print out timers
563-
for each phase of its execution. Its output (per-frontend) looks like this:
564-
565-
```
566-
===-------------------------------------------------------------------------===
567-
Swift compilation
568-
===-------------------------------------------------------------------------===
569-
Total Execution Time: 0.0876 seconds (0.0877 wall clock)
570-
571-
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
572-
0.0241 ( 53.9%) 0.0394 ( 92.0%) 0.0635 ( 72.5%) 0.0635 ( 72.5%) Import resolution
573-
0.0170 ( 38.0%) 0.0025 ( 5.8%) 0.0195 ( 22.3%) 0.0195 ( 22.2%) Type checking / Semantic analysis
574-
0.0013 ( 3.0%) 0.0004 ( 0.8%) 0.0017 ( 1.9%) 0.0017 ( 1.9%) LLVM output
575-
0.0010 ( 2.3%) 0.0003 ( 0.7%) 0.0013 ( 1.5%) 0.0013 ( 1.5%) SILGen
576-
0.0006 ( 1.4%) 0.0002 ( 0.4%) 0.0008 ( 0.9%) 0.0008 ( 0.9%) IRGen
577-
0.0004 ( 0.8%) 0.0000 ( 0.1%) 0.0004 ( 0.5%) 0.0004 ( 0.5%) SIL optimization
578-
0.0002 ( 0.5%) 0.0001 ( 0.1%) 0.0003 ( 0.3%) 0.0003 ( 0.3%) LLVM optimization
579-
0.0001 ( 0.1%) 0.0000 ( 0.1%) 0.0001 ( 0.1%) 0.0001 ( 0.1%) Parsing
580-
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) SIL verification (pre-optimization)
581-
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) SIL verification (post-optimization)
582-
0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) 0.0000 ( 0.0%) AST verification
583-
0.0448 (100.0%) 0.0428 (100.0%) 0.0876 (100.0%) 0.0877 (100.0%) Total
584-
```
585-
586562
- `-Xfrontend -debug-time-function-bodies`: asks each frontend to print out
587563
the time spent typechecking _every function_ in the program, sorted by time
588564
taken. The output is therefore voluminous, but can help when reducing a
@@ -1053,10 +1029,8 @@ getting slower between versions:
10531029
parameter of the script). Reconfirm that _just those two isolated frontend
10541030
processes_ still show the regression you're interested in isolating.
10551031
1056-
6. Check high-level diagnostic output between the two compilers, either the
1057-
newer unified stats reporter (`-stats-output-dir`) or the older flags
1058-
(`-Xfrontend -debug-time-compilation` and friends). Comparing the two will
1059-
often guide the search.
1032+
6. Check the value of performance counters between the two compilers via the
1033+
unified stats reporter (`-stats-output-dir`).
10601034
10611035
7. Run both frontend processes under a profiler and compare the profiles in
10621036
detail. At this point there ought to be _some_ sign of a difference, either

docs/DifferentiableProgramming.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,14 @@ extension Optional: Differentiable where Wrapped: Differentiable {
11921192

11931193
@noDerivative
11941194
public var zeroTangentVectorInitializer: () -> TangentVector {
1195-
{ TangentVector(.zero) }
1195+
switch self {
1196+
case nil:
1197+
return { TangentVector(nil) }
1198+
case let x?:
1199+
return { [zeroTanInit = x.zeroTangentVectorInitializer] in
1200+
TangentVector(zeroTanInit())
1201+
}
1202+
}
11961203
}
11971204
}
11981205
```

0 commit comments

Comments
 (0)