Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit f8d4829

Browse files
Dave AbrahamsMarc Rasi
authored andcommitted
Merge branch 'main' of github.com:apple/swift into tensorflow-stage
* 'main' of github.com:apple/swift: (67 commits) [build-script] Allow to tune dsymutil parallelism (swiftlang#34795) [Testing] Add missing REQUIRES [concurrency] SILGen: emit @asyncHandler functions. [concurrency] SILGen: allow the Builtin.createAsyncTaskFuture to have a non-generic closure argument. [concurrency] stdlib: add a _runAsyncHandler compiler intrinsic. Mangling: add support for mangling the body-function of asyncHandlers Make sure ~AutoDiffLinearMapContext() is called. fix SourceLoc-related crasher and add tests [AutoDiff] Bump-pointer allocate pullback structs in loops. (swiftlang#34886) update differentiable programming manifesto [Async CC] Always add full type metadata to bindings. [cxx-interop] Fix assertion to allow variadic members. [ome] Remove bad pattern of having a global SILBuilder with a global SILBuilderWithContext and multiple local SILBuilderWithScope. [ome] Invoke simplifyInstruction after lowering ownership and use replaceAllSimplifiedUsesAndErase instead of a manual RAUW. Partially revert Float16 availability changes (swiftlang#34847) Add a field reflection function that constructs keypaths. (swiftlang#34815) Allow the creation of a shadow variable when the type is a refcounted pointer (swiftlang#34835) [CMake] Extend copy-legacy-layouts dependency to swiftmodules (swiftlang#34846) [sil] Remove usage from TypeLowering of SILBuilder::create*AndFold(). [allocbox-to-stack] Fix an ossa bug in PromotedParamCloner. ...
2 parents cb89e64 + 8fc2598 commit f8d4829

File tree

207 files changed

+7615
-2855
lines changed

Some content is hidden

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

207 files changed

+7615
-2855
lines changed

docs/ContinuousIntegration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ preset=buildbot,tools=RA,stdlib=RD,test=non_executable
229229

230230
### Build and Test the Minimal Freestanding Stdlib using Toolchain Specific Preset Testing
231231

232-
To test the minimal freestanding stdlib on macho, you can use the support for running a miscellanous preset against a snapshot toolchain.
232+
To test the minimal freestanding stdlib on macho, you can use the support for running a miscellaneous preset against a snapshot toolchain.
233233

234234
```
235235
preset=stdlib_S_standalone_minimal_macho_x86_64,build,test

docs/DifferentiableProgramming.md

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

33
* Authors: [Richard Wei], [Dan Zheng], [Marc Rasi], [Bart Chrzaszcz]
4-
* Status: Partially implemented on master, feature gated under `import _Differentiation`
4+
* Status:
5+
* Partially implemented on main, feature gated under `import _Differentiation`
6+
* Initial proposal [pitched](https://forums.swift.org/t/differentiable-programming-for-gradient-based-machine-learning/42147) with a significantly scoped-down subset of features. Please refer to the linked pitch thread for the latest design discussions and changes.
57

68
## Table of contents
79

@@ -1271,6 +1273,12 @@ The synthesized `TangentVector` has the same effective access level as the
12711273
original type declaration. Properties in the synthesized `TangentVector` have
12721274
the same effective access level as their corresponding original properties.
12731275

1276+
The synthesized `TangentVector` adopts protocols from all `TangentVector`
1277+
conformance constraints implied by the declaration that triggers synthesis. For
1278+
example, synthesized `TangentVector`s always adopt the `AdditiveArithmetic` and
1279+
`Differentiable` protocols because the `Differentiable` protocol requires that
1280+
`TangentVector` conforms to `AdditiveArithmetic` and `Differentiable`.
1281+
12741282
The synthesized `move(along:)` method calls `move(along:)` for each pair of a
12751283
differentiable variable and its corresponding property in `TangentVector`.
12761284

include/swift/ABI/Class.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ enum class ObjCClassFlags : uint32_t {
5353
/// This class provides a non-trivial .cxx_destruct method, but
5454
/// its .cxx_construct is trivial. For backwards compatibility,
5555
/// when setting this flag, HasCXXStructors must be set as well.
56-
HasCXXDestructorOnly = 0x00100
56+
HasCXXDestructorOnly = 0x00100,
57+
58+
/// This class does not allow associated objects on instances.
59+
///
60+
/// Will cause the objc runtime to trap in objc_setAssociatedObject.
61+
ForbidsAssociatedObjects = 0x00400,
5762
};
5863
inline ObjCClassFlags &operator|=(ObjCClassFlags &lhs, ObjCClassFlags rhs) {
5964
lhs = ObjCClassFlags(uint32_t(lhs) | uint32_t(rhs));

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ class ASTContext final {
745745
/// Get the runtime availability of support for concurrency.
746746
AvailabilityContext getConcurrencyAvailability();
747747

748+
/// Get the runtime availability of support for differentiation.
749+
AvailabilityContext getDifferentiationAvailability();
750+
748751
/// Get the runtime availability of features introduced in the Swift 5.2
749752
/// compiler for the target platform.
750753
AvailabilityContext getSwift52Availability();

include/swift/AST/ASTMangler.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ASTMangler : public Mangler {
7777
public:
7878
enum class SymbolKind {
7979
Default,
80+
AsyncHandlerBody,
8081
DynamicThunk,
8182
SwiftAsObjCThunk,
8283
ObjCAsSwiftThunk,
@@ -323,16 +324,24 @@ class ASTMangler : public Mangler {
323324

324325
void appendAnyGenericType(const GenericTypeDecl *decl);
325326

326-
void appendFunction(AnyFunctionType *fn, bool isFunctionMangling = false,
327-
const ValueDecl *forDecl = nullptr);
327+
enum FunctionManglingKind {
328+
NoFunctionMangling,
329+
FunctionMangling,
330+
AsyncHandlerBodyMangling
331+
};
332+
333+
void appendFunction(AnyFunctionType *fn,
334+
FunctionManglingKind functionMangling = NoFunctionMangling,
335+
const ValueDecl *forDecl = nullptr);
328336
void appendFunctionType(AnyFunctionType *fn, bool isAutoClosure = false,
329337
const ValueDecl *forDecl = nullptr);
330338
void appendClangType(AnyFunctionType *fn);
331339
template <typename FnType>
332340
void appendClangType(FnType *fn, llvm::raw_svector_ostream &os);
333341

334342
void appendFunctionSignature(AnyFunctionType *fn,
335-
const ValueDecl *forDecl = nullptr);
343+
const ValueDecl *forDecl,
344+
FunctionManglingKind functionMangling);
336345

337346
void appendFunctionInputType(ArrayRef<AnyFunctionType::Param> params,
338347
const ValueDecl *forDecl = nullptr);
@@ -383,7 +392,10 @@ class ASTMangler : public Mangler {
383392
GenericSignature &genericSig,
384393
GenericSignature &parentGenericSig);
385394

386-
void appendDeclType(const ValueDecl *decl, bool isFunctionMangling = false);
395+
396+
397+
void appendDeclType(const ValueDecl *decl,
398+
FunctionManglingKind functionMangling = NoFunctionMangling);
387399

388400
bool tryAppendStandardSubstitution(const GenericTypeDecl *type);
389401

@@ -400,7 +412,7 @@ class ASTMangler : public Mangler {
400412

401413
void appendEntity(const ValueDecl *decl, StringRef EntityOp, bool isStatic);
402414

403-
void appendEntity(const ValueDecl *decl);
415+
void appendEntity(const ValueDecl *decl, bool isAsyncHandlerBody = false);
404416

405417
void appendProtocolConformance(const ProtocolConformance *conformance);
406418
void appendProtocolConformanceRef(const RootProtocolConformance *conformance);

include/swift/AST/Builtins.def

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,15 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(CreateAsyncTaskFuture,
752752
/// is a pure value and therefore we can consider it as readnone).
753753
BUILTIN_MISC_OPERATION_WITH_SILGEN(GlobalStringTablePointer, "globalStringTablePointer", "n", Special)
754754

755+
// autoDiffCreateLinearMapContext: (Builtin.Word) -> Builtin.NativeObject
756+
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffCreateLinearMapContext, "autoDiffCreateLinearMapContext", "n", Special)
757+
758+
// autoDiffProjectTopLevelSubcontext: (Builtin.NativeObject) -> Builtin.RawPointer
759+
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffProjectTopLevelSubcontext, "autoDiffProjectTopLevelSubcontext", "n", Special)
760+
761+
// autoDiffAllocateSubcontext: (Builtin.NativeObject, Builtin.Word) -> Builtin.RawPointer
762+
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffAllocateSubcontext, "autoDiffAllocateSubcontext", "", Special)
763+
755764
#undef BUILTIN_MISC_OPERATION_WITH_SILGEN
756765

757766
#undef BUILTIN_MISC_OPERATION

include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,9 @@ ERROR(attr_specialize_missing_comma,none,
15671567
ERROR(attr_specialize_unknown_parameter_name,none,
15681568
"unknown parameter %0 in '_specialize attribute'", (StringRef))
15691569

1570+
ERROR(attr_specialize_unsupported_exported_true ,none,
1571+
"'exported: true' has no effect in '_specialize' attribute", (StringRef))
1572+
15701573
ERROR(attr_specialize_expected_bool_value,none,
15711574
"expected a boolean true or false value in '_specialize' attribute", ())
15721575

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ REMARK(cross_import_added,none,
908908
"import of %0 and %1 triggered a cross-import of %2",
909909
(Identifier, Identifier, Identifier))
910910

911+
REMARK(module_loaded,none,
912+
"loaded module at %0",
913+
(StringRef))
914+
911915
// Operator decls
912916
ERROR(ambiguous_operator_decls,none,
913917
"ambiguous operator declarations found for operator", ())

include/swift/AST/ExtInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,10 @@ class SILExtInfo {
828828
return builder.withNoEscape(noEscape).build();
829829
}
830830

831+
SILExtInfo withAsync(bool isAsync = true) const {
832+
return builder.withAsync(isAsync).build();
833+
}
834+
831835
bool isEqualTo(SILExtInfo other, bool useClangTypes) const {
832836
return builder.isEqualTo(other.builder, useClangTypes);
833837
}

include/swift/AST/SemanticAttrs.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,10 @@ SEMANTICS_ATTR(KEYPATH_KVC_KEY_PATH_STRING, "keypath.kvcKeyPathString")
106106
/// consider inlining where to put these.
107107
SEMANTICS_ATTR(FORCE_EMIT_OPT_REMARK_PREFIX, "optremark")
108108

109+
/// An attribute that when attached to a class causes instances of the class to
110+
/// be forbidden from having associated objects set upon them. This is only used
111+
/// for testing purposes.
112+
SEMANTICS_ATTR(OBJC_FORBID_ASSOCIATED_OBJECTS, "objc.forbidAssociatedObjects")
113+
109114
#undef SEMANTICS_ATTR
110115

0 commit comments

Comments
 (0)