Skip to content

Commit 4808986

Browse files
Merge pull request #32623 from apple/tensorflow-merge
Merge 2020-06-30 into tensorflow
2 parents a16a047 + 2a45cd2 commit 4808986

File tree

689 files changed

+6930
-51099
lines changed

Some content is hidden

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

689 files changed

+6930
-51099
lines changed

CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,6 @@ if(NOT SWIFT_LIPO)
506506
find_toolchain_tool(SWIFT_LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
507507
endif()
508508

509-
# Reset CMAKE_SYSTEM_PROCESSOR if not cross-compiling.
510-
# CMake refuses to use `uname -m` on OS X
511-
# http://public.kitware.com/Bug/view.php?id=10326
512-
if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
513-
execute_process(
514-
COMMAND "uname" "-m"
515-
OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
516-
OUTPUT_STRIP_TRAILING_WHITESPACE)
517-
endif()
518-
519509
get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
520510
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
521511
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
106106

107107
#### macOS
108108

109-
To build for macOS, you need [Xcode 11.4](https://developer.apple.com/xcode/resources/).
109+
To build for macOS, you need [Xcode 12 beta](https://developer.apple.com/xcode/resources/).
110110
The required version of Xcode changes frequently, and is often a beta release.
111111
Check this document for the current required version.
112112

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,11 @@ function (swift_benchmark_compile_archopts)
660660
"-m${triple_platform}-version-min=${ver}"
661661
"-lobjc"
662662
"-L${SWIFT_LIBRARY_PATH}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}"
663+
"-L${sdk}/usr/lib/swift"
663664
"-Xlinker" "-rpath"
664665
"-Xlinker" "${SWIFT_LINK_RPATH}"
666+
"-Xlinker" "-rpath"
667+
"-Xlinker" "/usr/lib/swift"
665668
${bench_library_objects}
666669
${bench_driver_objects}
667670
${ld64_add_ast_path_opts}
@@ -694,7 +697,7 @@ function(swift_benchmark_compile)
694697
cmake_parse_arguments(SWIFT_BENCHMARK_COMPILE "" "PLATFORM" "" ${ARGN})
695698

696699
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE)
697-
set(stdlib_dependencies "swift")
700+
set(stdlib_dependencies "swift-frontend")
698701
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
699702
string(FIND "${stdlib_dependency}" "Unittest" find_output)
700703
if("${find_output}" STREQUAL "-1")

benchmark/single-source/Substring.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public let SubstringTest = [
1717
BenchmarkInfo(name: "EqualSubstringString", runFunction: run_EqualSubstringString, tags: [.validation, .api, .String]),
1818
BenchmarkInfo(name: "EqualSubstringSubstring", runFunction: run_EqualSubstringSubstring, tags: [.validation, .api, .String]),
1919
BenchmarkInfo(name: "EqualSubstringSubstringGenericEquatable", runFunction: run_EqualSubstringSubstringGenericEquatable, tags: [.validation, .api, .String]),
20+
BenchmarkInfo(name: "SubstringRemoveFirst1", runFunction: run_SubstringRemoveFirst1, tags: [.validation, .api, .String]),
21+
BenchmarkInfo(name: "SubstringRemoveLast1", runFunction: run_SubstringRemoveLast1, tags: [.validation, .api, .String]),
2022
BenchmarkInfo(name: "LessSubstringSubstring", runFunction: run_LessSubstringSubstring, tags: [.validation, .api, .String]),
2123
BenchmarkInfo(name: "LessSubstringSubstringGenericComparable", runFunction: run_LessSubstringSubstringGenericComparable, tags: [.validation, .api, .String]),
2224
BenchmarkInfo(name: "StringFromLongWholeSubstring", runFunction: run_StringFromLongWholeSubstring, tags: [.validation, .api, .String]),
@@ -34,6 +36,8 @@ let longWide = "fὢasὢodὢijὢadὢolὢsjὢalὢsdὢjlὢasὢdfὢijὢ
3436
let (s1, ss1) = equivalentWithDistinctBuffers()
3537
let (s2, ss2) = equivalentWithDistinctBuffers()
3638

39+
let quiteLong = String(repeating: "0", count: 10_000)[...]
40+
3741
@inline(never)
3842
public func run_SubstringFromLongString(_ N: Int) {
3943
var s = longWide
@@ -126,6 +130,24 @@ public func run_EqualSubstringSubstringGenericEquatable(_ N: Int) {
126130
}
127131
}
128132

133+
@inline(never)
134+
public func run_SubstringRemoveFirst1(_ N: Int) {
135+
for _ in 1...N {
136+
var s = quiteLong
137+
s.removeFirst(1)
138+
blackHole(s.first == "0")
139+
}
140+
}
141+
142+
@inline(never)
143+
public func run_SubstringRemoveLast1(_ N: Int) {
144+
for _ in 1...N {
145+
var s = quiteLong
146+
s.removeLast(1)
147+
blackHole(s.first == "0")
148+
}
149+
}
150+
129151
/*
130152
func checkEqual<T, U>(_ x: T, _ y: U)
131153
where T : StringProtocol, U : StringProtocol {

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function(_swift_gyb_target_sources target scope)
2323

2424
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${generated}
2525
COMMAND
26-
$<TARGET_FILE:Python2::Interpreter> ${SWIFT_SOURCE_DIR}/utils/gyb -D CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P} ${SWIFT_GYB_FLAGS} -o ${CMAKE_CURRENT_BINARY_DIR}/${generated}.tmp ${absolute}
26+
$<TARGET_FILE:Python3::Interpreter> ${SWIFT_SOURCE_DIR}/utils/gyb -D CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P} ${SWIFT_GYB_FLAGS} -o ${CMAKE_CURRENT_BINARY_DIR}/${generated}.tmp ${absolute}
2727
COMMAND
2828
${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${generated}.tmp ${CMAKE_CURRENT_BINARY_DIR}/${generated}
2929
COMMAND

cmake/modules/AddSwiftUnittests.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ function(add_swift_unittest test_dirname)
5757
_ENABLE_EXTENDED_ALIGNED_STORAGE)
5858
endif()
5959

60-
if(SWIFT_USE_LINKER)
61-
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
62-
LINK_FLAGS " -fuse-ld=${SWIFT_USE_LINKER}")
60+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
61+
if(SWIFT_USE_LINKER)
62+
target_link_options(${test_dirname} PRIVATE
63+
-fuse-ld=${SWIFT_USE_LINKER}$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
64+
endif()
6365
endif()
6466

6567
if(SWIFT_ANALYZE_CODE_COVERAGE)

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
include(SwiftAddCustomCommandTarget)
22
include(SwiftSetIfArchBitness)
33

4-
find_package(Python2 COMPONENTS Interpreter REQUIRED)
5-
64
# Create a target to process single gyb source with the 'gyb' tool.
75
#
86
# handle_gyb_source_single(
@@ -60,7 +58,7 @@ function(handle_gyb_source_single dependency_out_var_name)
6058
COMMAND
6159
"${CMAKE_COMMAND}" -E make_directory "${dir}"
6260
COMMAND
63-
"$<TARGET_FILE:Python2::Interpreter>" "${gyb_tool}" ${SWIFT_GYB_FLAGS} ${GYB_SINGLE_FLAGS} -o "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_SOURCE}"
61+
"$<TARGET_FILE:Python3::Interpreter>" "${gyb_tool}" ${SWIFT_GYB_FLAGS} ${GYB_SINGLE_FLAGS} -o "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_SOURCE}"
6462
COMMAND
6563
"${CMAKE_COMMAND}" -E copy_if_different "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_OUTPUT}"
6664
COMMAND

docs/Android.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ $ NDK_PATH="path/to/android-ndk21"
103103
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step.
104104
# The location of the tools used to build Android binaries
105105
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
106-
-target armv7a-none-linux-androideabi \ # Targeting android-armv7.
107-
-sdk ${NDK_PATH}/platforms/android-21/arch-arm \ # Use the same architecture and API version as you used to build the stdlib in the previous step.
108-
-Xclang-linker -nostdlib++ \ # Don't link libc++, and supply the path to libgcc.
106+
-target armv7a-none-linux-androideabi \ # Targeting android-armv7, and supply the path to libgcc.
109107
-L ${NDK_PATH}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a \
108+
-sdk ${NDK_PATH}/platforms/android-21/arch-arm \ # Use the same architecture and API version as you used to build the stdlib in the previous step.
110109
hello.swift
111110
```
112111

docs/DifferentiableProgramming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Differentiable Programming Manifesto
22

33
* Authors: [Richard Wei], [Dan Zheng], [Marc Rasi], [Bart Chrzaszcz]
4-
* Status: Partially implemented
4+
* Status: Partially implemented on master, feature gated under `import _Differentiation`
55

66
## Table of contents
77

docs/ExternalResources.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# External Resources
2+
3+
The official [Swift blog](https://swift.org/blog/) has a lot of useful
4+
information, such as [how runtime reflection works][mirror-post] and how the
5+
compiler's [new diagnostic architecture][diagnostic-arch-post] is structured.
6+
7+
[mirror-post]: https://swift.org/blog/how-mirror-works/
8+
[diagnostic-arch-post]: https://swift.org/blog/new-diagnostic-arch-overview/
9+
10+
This page lists some external resources apart from the Swift blog which may be
11+
helpful for people interested in contributing to Swift. The resources are listed
12+
in reverse-chronological order and organized by topic.
13+
14+
<!--
15+
Some resources don't fall cleanly into one topic bucket or another; in such a
16+
case we break the tie arbitrarily.
17+
-->
18+
19+
<!--
20+
The textual descriptions should be written in a way that makes it clear
21+
which topics are discussed, and what a potential contributor to Swift
22+
will gain from it. This is usually different from the talk's abstract.
23+
-->
24+
25+
## Contributing Guides and Tips
26+
27+
- [Steps for first PR and asking questions][] by Varun Gandhi (Swift forum
28+
comment, Dec 2019).
29+
- [Contributing to Swift for the First Time][] by Robert Pieta (talk, Jun 2019):
30+
This talk describes Robert's experience contributing to
31+
`swift-corelibs-foundation` and later `swift`, providing a step-by-step guide
32+
for new contributors to get their feet wet.
33+
- [Contributing to Swift compiler][] by Yusuke Kita (lightning talk, Apr 2019).
34+
- Contributing to Swift ([Part 1][Contributing to Swift - Part 1],
35+
[Part 2][Contributing to Swift - Part 2]) by Suyash Srijan (blog post series,
36+
Dec 2018).
37+
- [Setting up a compile-edit-test cycle][] by Robert Widmann (Swift forum
38+
comment, May 2018)
39+
- [Becoming an Effective Contributor to Swift][] by Harlan Haskins and Robert
40+
Widmann (talk, Apr 2018): Covers the following topics:
41+
- The organization of different projects part of the Swift monorepo.
42+
- How to set up an environment for building Swift.
43+
- Common utilities and compiler flags for debugging different stages.
44+
- Common build configurations.
45+
- Tips and tricks for testing: early exiting, filtering tests,
46+
testing Swift and Objective-C together, using `PrettyStackTrace`.
47+
- A live demo fixing a crash:
48+
- Copying program arguments into Xcode for debugging.
49+
- Using `dump()` for print debugging.
50+
- [Getting Started with Swift Compiler Development][] by Brian Gesiak (blog post
51+
series, Aug 2017 - Jun 2018)
52+
- [Contributing to Open Source Swift][] by Jesse Squires (talk, Mar 2016):
53+
Covers the following topics:
54+
- The overall compiler pipeline.
55+
- The organization of different projects part of the Swift monorepo,
56+
including some "difficulty levels" for different projects.
57+
- Tips for contributing effectively.
58+
59+
[Steps for first PR and asking questions]:
60+
https://forums.swift.org/t/getting-started-with-swift-compiler-development/31502/2
61+
[Contributing to Swift for the First Time]: https://youtu.be/51j7TrFNKiA
62+
[Contributing to Swift compiler]: https://youtu.be/HAXJsgYniqE
63+
[Contributing to Swift - Part 1]: https://medium.com/kinandcartacreated/contributing-to-swift-part-1-ea19108a2a54
64+
[Contributing to Swift - Part 2]:
65+
https://medium.com/kinandcartacreated/contributing-to-swift-part-2-efebcf7b6c93
66+
[Setting up a compile-edit-test cycle]: https://forums.swift.org/t/need-a-workflow-advice/12536/14
67+
[Becoming an Effective Contributor to Swift]: https://youtu.be/oGJKsp-pZPk
68+
[Getting Started with Swift Compiler Development]: https://modocache.io/getting-started-with-swift-development
69+
[Contributing to Open Source Swift]: https://youtu.be/Ysa2n8ZX-YY
70+
71+
## AST
72+
73+
- [The secret life of types in Swift][] by Slava Pestov (blog post, Jul 2016):
74+
This blog post describes the representation of Swift types inside the compiler.
75+
It covers many important concepts: `TypeLoc` vs `TypeRepr` vs `Type`, the
76+
representation of generic types, substitutions and more.
77+
<!-- TODO: It would be great to integrate some of the descriptions
78+
in this blog post into the compiler's own doc comments. -->
79+
80+
[The secret life of types in Swift]: https://medium.com/@slavapestov/the-secret-life-of-types-in-swift-ff83c3c000a5
81+
82+
### libSyntax and SwiftSyntax
83+
84+
- [An overview of SwiftSyntax][] by Luciano Almeida (blog post, Apr 2019):
85+
This post provides a quick tour of libSyntax and SwiftSyntax.
86+
- [Improving Swift Tools with libSyntax][] by Harlan Haskins (talk, Sep 2017):
87+
This talk describes the design of libSyntax/SwiftSyntax and discusses some
88+
useful APIs. It also describes how to write a simple Swift formatter using the
89+
library.
90+
91+
[An overview of SwiftSyntax]: https://medium.com/@lucianoalmeida1/an-overview-of-swiftsyntax-cf1ae6d53494
92+
[Improving Swift Tools with libSyntax]: https://youtu.be/5ivuYGxW_3M
93+
94+
## Type checking and inference
95+
96+
- [Implementing Swift Generics][] by Slava Pestov and John McCall (talk, Oct 2017):
97+
This talk dives into how Swift's compilation scheme for generics balances
98+
(a) modularity and separate compilation with (b) the ability to pass unboxed
99+
values and (c) the flexibility to optionally generate fully specialized code.
100+
It covers the following type-checking related topics: type-checking generic
101+
contexts, requirement paths and canonicalized generic signatures.
102+
- [A Type System from Scratch][] by Robert Widmann (talk, Apr 2017):
103+
This talk covers several topics related to type-checking and inference in Swift:
104+
- Understanding sequent notation which can be used to represent typing judgments.
105+
- An overview of how bidirectional type-checking works.
106+
- Examples of checking and inferring types for some Swift expressions.
107+
- Interaction complexity of different type system features with type inference.
108+
- Type variables and constraint graphs.
109+
110+
[Implementing Swift Generics]: https://youtu.be/ctS8FzqcRug
111+
[A Type System from Scratch]: https://youtu.be/IbjoA5xVUq0
112+
113+
## SIL
114+
115+
- [Ownership SSA][] by Michael Gottesman (talk, Oct 2019): This talk describes
116+
efficiency and correctness challenges with automatic reference counting and
117+
how including ownership semantics in the compiler's intermediate representation
118+
helps tackles those challenges.
119+
- [How to talk to your kids about SIL type use][] by Slava Pestov (blog post,
120+
Jul 2016): This blog post describes several important SIL concepts: object
121+
vs address types, AST -> SIL type lowering, trivial vs loadable vs
122+
address-only SIL types, abstraction patterns and more.
123+
- [Swift's High-Level IR][] by Joe Groff and Chris Lattner (talk, Oct 2015):
124+
This talk describes the goals and design of SIL. It covers the following:
125+
- Some commonly used SIL instructions and how they are motivated by language
126+
features.
127+
- Some early passes in SIL processing, such as mandatory inlining,
128+
box-to-stack promotion and definite initialization.
129+
- Why SIL is useful as an intermediate representation between the AST and
130+
LLVM IR.
131+
132+
[Ownership SSA]: https://youtu.be/qy3iZPHZ88o
133+
[How to talk to your kids about SIL type use]: https://medium.com/@slavapestov/how-to-talk-to-your-kids-about-sil-type-use-6b45f7595f43
134+
[Swift's High-Level IR]: https://youtu.be/Ntj8ab-5cvE
135+
136+
## Code generation, runtime and ABI
137+
138+
- [How Swift Achieved Dynamic Linking Where Rust Couldn't][] by Alexis
139+
Beingessner (blog post, Nov 2019): This blog post describes Swift's approach
140+
for compiling polymorphic functions, contrasting it with the strategy used by
141+
Rust and C++ (monomorphization). It covers the following topics: ABI stability,
142+
library evolution, resilient type layout, reabstraction, materialization,
143+
ownership and calling conventions.
144+
- [arm64e: An ABI for Pointer Authentication][] by Ahmed Bougacha and John McCall
145+
(talk, Oct 2019): This talk does not mention Swift specifically, but provides a
146+
good background on the arm64e ABI and pointer authentication. The ABI affects
147+
parts of IR generation, the Swift runtime, and small parts of the standard
148+
library using unsafe code.
149+
- [Exploiting The Swift ABI][] by Robert Widmann (talk, July 2019):
150+
This talk is a whirlwind tour of different aspects of the Swift ABI and runtime
151+
touching the following topics: reflection, type layout, ABI entrypoints,
152+
Swift's compilation model for generics and archetypes, witness tables,
153+
relative references, context descriptors and more.
154+
- [Efficiently Implementing Runtime Metadata][] by Joe Groff and Doug Gregor
155+
(talk, Oct 2018): This talk covers the use of relative references in Swift's
156+
runtime metadata structures. After describing some important metrics impacted
157+
by the use of dynamic libraries, it goes through the different kinds of
158+
relative references used in the Swift runtime and the resulting tooling and
159+
performance benefits.
160+
- [Coroutine Representations and ABIs in LLVM][] by John McCall (talk, Oct 2018):
161+
This talk describes several points in the design space for coroutines, diving
162+
into important implementation tradeoffs. It explains how different language
163+
features can be built on top of coroutines and how they impose different
164+
design requirements. It also contrasts C++20's coroutines feature with
165+
Swift's accessors, describing the differences between the two as implemented
166+
in LLVM.
167+
- [Implementing Swift Generics][]: This talk is mentioned in the type-checking
168+
section. It also covers the following code generation and runtime topics:
169+
value witness tables, type metadata, abstraction patterns, reabstraction,
170+
reabstraction thunks and protocol witness tables.
171+
172+
[How Swift Achieved Dynamic Linking Where Rust Couldn't]: https://gankra.github.io/blah/swift-abi/
173+
[arm64e: An ABI for Pointer Authentication]: https://youtu.be/C1nZvpEBfYA
174+
[Exploiting The Swift ABI]: https://youtu.be/0rHG_Pa86oA
175+
[Efficiently Implementing Runtime Metadata]: https://youtu.be/G3bpj-4tWVU
176+
[Coroutine Representations and ABIs in LLVM]: https://youtu.be/wyAbV8AM9PM

0 commit comments

Comments
 (0)