Skip to content

Commit bc32cf9

Browse files
committed
Merge branch 'tensorflow' into TF-496-conform-SIMD-types-differentiable
2 parents 2821b8f + c224468 commit bc32cf9

File tree

768 files changed

+11559
-11640
lines changed

Some content is hidden

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

768 files changed

+11559
-11640
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,26 @@ more environments.
105105

106106
To build using Ninja, run:
107107

108-
utils/build-script --enable-tensorflow --release-debuginfo
108+
swift/utils/build-script --enable-tensorflow --release-debuginfo
109109

110110
When developing Swift, it helps to build what you're working on in a debug
111111
configuration while building the rest of the project with optimizations. Below
112112
are some examples of using debug variants:
113113

114-
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift # Swift frontend built in debug
115-
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift-stdlib # Standard library built in debug
116-
utils/build-script --enable-tensorflow --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
114+
swift/utils/build-script --enable-tensorflow --release-debuginfo --debug-swift # Swift frontend built in debug
115+
swift/utils/build-script --enable-tensorflow --release-debuginfo --debug-swift-stdlib # Standard library built in debug
116+
swift/utils/build-script --enable-tensorflow --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
117117

118118
Limiting the amount of debug code in the compiler has a very large impact on
119119
Swift compile times, and in turn the test execution time. If you want to build
120120
the entire project in debug, you can run:
121121

122-
utils/build-script --enable-tensorflow --debug
122+
swift/utils/build-script --enable-tensorflow --debug
123123

124124
For documentation of all available arguments, as well as additional usage
125125
information, see the inline help:
126126

127-
utils/build-script -h
127+
swift/utils/build-script -h
128128

129129
### Customize TensorFlow support
130130

@@ -217,7 +217,7 @@ This script is used by swift.org's CI to produce snapshots and can allow for one
217217
locally reproduce such builds for development or distribution purposes. E.x.:
218218

219219
```
220-
$ ./utils/build-toolchain-tensorflow $BUNDLE_PREFIX
220+
$ ./swift/utils/build-toolchain-tensorflow $BUNDLE_PREFIX
221221
```
222222

223223
where ``$BUNDLE_PREFIX`` is a string that will be prepended to the build
File renamed without changes.

docs/ABI/RegisterUsage.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## 64-Bit Architecture Register Usage
2+
3+
From Swift 5, the calling convention register allocation for 64-bit architectures is largely based on [existing](https://developer.apple.com/library/content/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html) [standards](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/LowLevelABI/140-x86-64_Function_Calling_Conventions/x86_64.html), with the addition of the context and error return registers discussed in the [ABI stability manifesto](https://github.com/apple/swift/blob/master/docs/ABIStabilityManifesto.md):
4+
5+
| Register Purpose | ARM64 | x86_64 |
6+
| ------------- |:-------------:| ----- |
7+
| Context register (self) | x20 | r13 |
8+
| Error return register | x21 | r12 |
9+
| Struct return pointer | x8 | rax |
10+
| Float call arguments | v0 … v7 | xmm0 … xmm7 |
11+
| Integer call arguments | x0 … x7 | rdi, rsi, rdx, rcx, r8, r9 |
12+
| Float return | v0 … v3 | xmm0 … xmm3 |
13+
| Integer return | x0 … x3 | rax, rdx, rcx, r8 |

docs/ABIStabilityManifesto.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ Having the call context register be callee-saved is advantageous. It keeps the r
337337

338338
Throwing functions communicate error values to their callers through the *error* register on some platforms. The error register holds a pointer to the error value if an error occurred, otherwise 0. The caller of a throwing function is expected to quickly check for 0 before continuing on with non-error code, otherwise branching to code to handle or propagate the error. Using a callee-saved register for the error register enables free conversion from non-throwing to throwing functions, which is required to honor the subtyping relationship.
339339

340+
The specific registers used in these roles are documented in [another document on register usage](https://github.com/apple/swift/blob/master/docs/ABI/RegisterUsage.md).
341+
340342
### <a name="function-signature-lowering"></a>Function Signature Lowering
341343

342344
Function signature lowering is the mapping of a function's source-language type, which includes formal parameters and results, all the way down to a physical convention, which dictates what values are stored in what registers and what values to pass on the stack.

docs/CompilerPerformance.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,6 @@ $ cat /tmp/stats/*.json
717717
"AST.NumSourceLinesPerSecond": 3,
718718
"AST.NumLinkLibraries": 0,
719719
"AST.NumLoadedModules": 4,
720-
"AST.NumImportedExternalDefinitions": 0,
721720
"AST.NumTotalClangImportedEntities": 0,
722721
...
723722
"time.swift.Parsing.wall": 5.038023e-03,

docs/DebuggingTheCompiler.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,44 @@ One can also use shell regex to visit multiple files in the same directory. Exam
457457

458458
clang-tidy -p=$PATH_TO_BUILD/swift-macosx-x86_64/compile_commands.json $FULL_PATH_TO_DIR/*.cpp
459459

460+
Identifying an optimizer bug
461+
----------------------------
462+
463+
If a compiled executable is crashing when built with optimizations, but not
464+
crashing when built with -Onone, it's most likely one of the SIL optimizations
465+
which causes the miscompile.
466+
467+
Currently there is no tool to automatically identify the bad optimization, but
468+
it's quite easy to do this manually:
469+
470+
1. Find the offending optimization with bisecting:
471+
472+
a. Add the compiler option ``-Xllvm -sil-opt-pass-count=<n>``, where ``<n>``
473+
is the number of optimizations to run.
474+
b. Bisect: find n where the executable crashes, but does not crash with n-1.
475+
Note that n can be quite large, e.g. > 100000 (just try
476+
n = 10, 100, 1000, 10000, etc. to find an upper bound).
477+
c. Add another option ``-Xllvm -sil-print-pass-name``. The output can be
478+
large, so it's best to redirect stderr to a file (``2> output``).
479+
In the output search for the last pass before ``stage Address Lowering``.
480+
It should be the ``Run #<n-1>``. This line tells you the name of the bad
481+
optimization pass and on which function it run.
482+
483+
2. Get the SIL before and after the bad optimization.
484+
485+
a. Add the compiler options
486+
``-Xllvm -sil-print-all -Xllvm -sil-print-only-function='<function>'``
487+
where ``<function>`` is the function name (including the preceding ``$``).
488+
For example:
489+
``-Xllvm -sil-print-all -Xllvm -sil-print-only-function='$s4test6testityS2iF'``.
490+
Again, the output can be large, so it's best to redirect stderr to a file.
491+
b. From the output, copy the SIL of the function *before* the bad
492+
run into a separate file and the SIL *after* the bad run into a file.
493+
c. Compare both SIL files and try to figure out what the optimization pass
494+
did wrong. To simplify the comparison, it's sometimes helpful to replace
495+
all SIL values (e.g. ``%27``) with a constant string (e.g. ``%x``).
496+
497+
460498
Debugging Swift Executables
461499
===========================
462500

docs/SIL.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,15 +2333,15 @@ with a sequence that also correctly destroys the current value.
23332333
This instruction is only valid in Raw SIL and is rewritten as appropriate
23342334
by the definitive initialization pass.
23352335

2336-
assign_by_delegate
2336+
assign_by_wrapper
23372337
``````````````````
23382338
::
23392339

2340-
sil-instruction ::= 'assign_by_delegate' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
2340+
sil-instruction ::= 'assign_by_wrapper' sil-operand 'to' sil-operand ',' 'init' sil-operand ',' 'set' sil-operand
23412341

2342-
assign_by_delegate %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
2342+
assign_by_wrapper %0 : $S to %1 : $*T, init %2 : $F, set %3 : $G
23432343
// $S can be a value or address type
2344-
// $T must be the type of a property delegate.
2344+
// $T must be the type of a property wrapper.
23452345
// $F must be a function type, taking $S as a single argument and returning $T
23462346
// $G must be a function type, taking $S as a single argument and with not return value
23472347

docs/WindowsBuild.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ git clone https://github.com/apple/swift-cmark cmark
4040
git clone https://github.com/apple/swift-clang clang
4141
git clone https://github.com/apple/swift-llvm llvm
4242
git clone https://github.com/apple/swift-compiler-rt compiler-rt
43-
git clone -c core.autocrlf=input https://github.com/apple/swift
43+
git clone -c core.autocrlf=input -c core.symlinks=true https://github.com/apple/swift
4444
git clone https://github.com/apple/swift-corelibs-libdispatch
4545
git clone https://github.com/apple/swift-corelibs-foundation
4646
git clone https://github.com/apple/swift-corelibs-xctest
@@ -101,7 +101,7 @@ Warning: Creating the above links usually requires administrator privileges. The
101101
## 6. Build LLVM/Clang
102102
- This must be done from within a developer command prompt. LLVM and Clang are
103103
large projects, so building might take a few hours. Make sure that the build
104-
type for LLVM/Clang is compatbile with the build type for Swift. That is,
104+
type for LLVM/Clang is compatible with the build type for Swift. That is,
105105
either build everything `Debug` or some variant of `Release` (e.g. `Release`,
106106
`RelWithDebInfo`).
107107
```cmd
@@ -158,10 +158,10 @@ cmake -G Ninja^
158158
-DLLVM_DIR=S:\b\llvm\lib\cmake\llvm^
159159
-DClang_DIR=S:\b\llvm\lib\cmake\clang^
160160
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE="S:\swift-corelibs-libdispatch"^
161-
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/thirdparty/icu4c-63_1-Win64-MSVC2017/include"^
162-
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:/thirdparty/icu4c-63_1-Win64-MSVC2017/lib64/icuuc.lib"^
163-
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/thirdparty/icu4c-63_1-Win64-MSVC2017/include"^
164-
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/thirdparty/icu4c-63_1-Win64-MSVC2017/lib64/icuin.lib"^
161+
-DSWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE="S:/thirdparty/icu4c-64_2-Win64-MSVC2017/include"^
162+
-DSWIFT_WINDOWS_x86_64_ICU_UC="S:/thirdparty/icu4c-64_2-Win64-MSVC2017/lib64/icuuc.lib"^
163+
-DSWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE="S:/thirdparty/icu4c-64_2-Win64-MSVC2017/include"^
164+
-DSWIFT_WINDOWS_x86_64_ICU_I18N="S:/thirdparty/icu4c-64_2-Win64-MSVC2017/lib64/icuin.lib"^
165165
-DCMAKE_INSTALL_PREFIX="C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr"^
166166
-DPYTHON_EXECUTABLE=C:\Python27\python.exe^
167167
S:\swift
@@ -204,7 +204,7 @@ ninja
204204
Running the testsuite on Windows has additional external dependencies.
205205

206206
```cmd
207-
path S:\thirdparty\icu4c-63_1-Win64-MSVC2017\bin64;S:\b\swift\bin;S:\b\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
207+
path S:\thirdparty\icu4c-64_2-Win64-MSVC2017\bin64;S:\b\swift\bin;S:\b\swift\libdispatch-prefix\bin;%PATH%;%ProgramFiles%\Git\usr\bin
208208
ninja -C S:\b\swift check-swift
209209
```
210210

@@ -258,7 +258,7 @@ cmake -G Ninja^
258258
-DCURL_LIBRARY="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
259259
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/include"^
260260
-DENABLE_TESTING=NO^
261-
-DICU_ROOT="S:/thirdparty/icu4c-63_1-Win64-MSVC2017"^
261+
-DICU_ROOT="S:/thirdparty/icu4c-64_2-Win64-MSVC2017"^
262262
-DLIBXML2_LIBRARY="S:/libxml2/win32/bin.msvc/libxml2_a.lib"^
263263
-DLIBXML2_INCLUDE_DIR="S:/libxml2/include"^
264264
-DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch^
@@ -312,7 +312,7 @@ cmake -G Ninja^
312312
-DCURL_LIBRARY="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/lib/libcurl_a.lib"^
313313
-DCURL_INCLUDE_DIR="S:/curl/builds/libcurl-vc15-x64-release-static-ipv6-sspi-winssl/include"^
314314
-DENABLE_TESTING=YES^
315-
-DICU_ROOT="S:/thirdparty/icu4c-63_1-Win64-MSVC2017"^
315+
-DICU_ROOT="S:/thirdparty/icu4c-64_2-Win64-MSVC2017"^
316316
-DLIBXML2_LIBRARY="S:/libxml2/win32/bin.msvc/libxml2_a.lib"^
317317
-DLIBXML2_INCLUDE_DIR="S:/libxml2/include"^
318318
-DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch^

include/swift/ABI/Metadata.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,10 +3121,6 @@ struct MetadataCompletionContext {
31213121
/// it may be called many times as successive dependencies are resolved.
31223122
/// If the function ever completes successfully (by returning null), it
31233123
/// will not be called again for the same type.
3124-
///
3125-
/// \return null to indicate that the type has been completed, or a non-null
3126-
/// pointer to indicate that completion is blocked on the completion of
3127-
/// some other type
31283124
using MetadataCompleter =
31293125
SWIFT_CC(swift)
31303126
MetadataDependency(const Metadata *type,

include/swift/AST/ASTContext.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,6 @@ class ASTContext final {
259259
#define IDENTIFIER_WITH_NAME(Name, IdStr) Identifier Id_##Name;
260260
#include "swift/AST/KnownIdentifiers.def"
261261

262-
/// The list of external definitions imported by this context.
263-
llvm::SetVector<Decl *> ExternalDefinitions;
264-
265-
/// FIXME: HACK HACK HACK
266-
/// This state should be tracked somewhere else.
267-
unsigned LastCheckedExternalDefinition = 0;
268-
269262
/// A consumer of type checker debug output.
270263
std::unique_ptr<TypeCheckerDebugConsumer> TypeCheckerDebug;
271264

@@ -606,14 +599,8 @@ class ASTContext final {
606599
ForeignLanguage language,
607600
const DeclContext *dc);
608601

609-
/// Add a declaration to a list of declarations that need to be emitted
610-
/// as part of the current module or source file, but are otherwise not
611-
/// nested within it.
612-
void addExternalDecl(Decl *decl);
613-
614602
/// Add a declaration that was synthesized to a per-source file list if
615-
/// if is part of a source file, or the external declarations list if
616-
/// it is part of an imported type context.
603+
/// if is part of a source file.
617604
void addSynthesizedDecl(Decl *decl);
618605

619606
/// Add a cleanup function to be called when the ASTContext is deallocated.
@@ -877,11 +864,11 @@ class ASTContext final {
877864
const IterableDeclContext *idc,
878865
LazyMemberLoader *lazyLoader);
879866

880-
/// Access the side cache for property delegate backing property types,
867+
/// Access the side cache for property wrapper backing property types,
881868
/// used because TypeChecker::typeCheckBinding() needs somewhere to stash
882869
/// the backing property type.
883-
Type getSideCachedPropertyDelegateBackingPropertyType(VarDecl *var) const;
884-
void setSideCachedPropertyDelegateBackingPropertyType(VarDecl *var,
870+
Type getSideCachedPropertyWrapperBackingPropertyType(VarDecl *var) const;
871+
void setSideCachedPropertyWrapperBackingPropertyType(VarDecl *var,
885872
Type type);
886873

887874
/// Returns memory usage of this ASTContext.

include/swift/AST/ASTTypeIDZone.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
1818
SWIFT_TYPEID_NAMED(VarDecl *, VarDecl)
1919
SWIFT_TYPEID(Type)
20-
SWIFT_TYPEID(PropertyDelegateBackingPropertyInfo)
21-
SWIFT_TYPEID(PropertyDelegateTypeInfo)
20+
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
21+
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2222
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
2323
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

include/swift/AST/ASTTypeIDs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ namespace swift {
2222

2323
class CustomAttr;
2424
class NominalTypeDecl;
25-
struct PropertyDelegateBackingPropertyInfo;
26-
struct PropertyDelegateTypeInfo;
25+
struct PropertyWrapperBackingPropertyInfo;
26+
struct PropertyWrapperTypeInfo;
2727
class Type;
2828
class VarDecl;
2929
class TypeAliasDecl;

include/swift/AST/Attr.def

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,11 @@ SIMPLE_DECL_ATTR(_weakLinked, WeakLinked,
368368
OnNominalType | OnAssociatedType | OnFunc | OnAccessor | OnVar |
369369
OnSubscript | OnConstructor | OnEnumElement | OnExtension | UserInaccessible,
370370
75)
371-
SIMPLE_DECL_ATTR(_frozen, Frozen,
372-
OnEnum |
371+
SIMPLE_DECL_ATTR(frozen, Frozen,
372+
OnEnum | OnStruct |
373373
UserInaccessible,
374374
76)
375+
DECL_ATTR_ALIAS(_frozen, Frozen)
375376
SIMPLE_DECL_ATTR(_forbidSerializingReference, ForbidSerializingReference,
376377
OnAnyDecl |
377378
LongAttribute | RejectByParser | UserInaccessible | NotSerialized,
@@ -403,7 +404,7 @@ SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
403404
DECL_ATTR(_custom, Custom,
404405
OnAnyDecl | UserInaccessible,
405406
85)
406-
SIMPLE_DECL_ATTR(_propertyDelegate, PropertyDelegate,
407+
SIMPLE_DECL_ATTR(_propertyWrapper, PropertyWrapper,
407408
OnStruct | OnClass | OnEnum,
408409
86)
409410
SIMPLE_DECL_ATTR(_disfavoredOverload, DisfavoredOverload,
@@ -421,10 +422,8 @@ DECL_ATTR(differentiating, Differentiating,
421422
SIMPLE_DECL_ATTR(compilerEvaluable, CompilerEvaluable,
422423
OnAccessor | OnFunc | OnConstructor | OnSubscript,
423424
/* Not serialized */ 90)
424-
SIMPLE_DECL_ATTR(_fieldwiseDifferentiable, FieldwiseDifferentiable,
425-
OnNominalType | UserInaccessible, 91)
426425
SIMPLE_DECL_ATTR(noDerivative, NoDerivative,
427-
OnVar, 92)
426+
OnVar, 91)
428427

429428
#undef TYPE_ATTR
430429
#undef DECL_ATTR_ALIAS

0 commit comments

Comments
 (0)