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

Commit 693b509

Browse files
committed
Merge branch 'main' of github.com:apple/swift into tensorflow-stage
* 'main' of github.com:apple/swift: (22 commits) Dynamic Casting: Properly unwrap existential metatype sources (swiftlang#34469) Add -allow-critical-edges=false to copyforward_ossa.sil Add -allow-critical-edges flag. Sema: Check result builder availability Sema: Pass ExportContext by const reference where possible Sema: Put the AvailabilityContext inside the ExportContext Change interfaces to accept a FileCollectorBase [Parse] Remove unused declaration and diagnostic message [cxx-interop] Use regex instead of operand name to fix C++ constructor tests. [CodeCompletion] Fix a crash in collectPossibleReturnTypesFromContext [test] Update cross_langauge index test for mangling change Temporarily disable this test [Concurrency] SIL: add hop_to_executor instruction sil-opt: add an -enable-experimental-concurrency option. Sema: Don't visit elements of a BraceStmt twice when checking availability Sema: Rename AvailabilityWalker to ExprAvailabilityWalker Sema: Pull diagnoseDeclAvailability() out of AvailabilityWalker Sema: Rename some availability checking entry points SILGen: Stub out support for invoking foreign async methods. Add a mangling for completion block implementation functions. ...
2 parents a5700a7 + 142b726 commit 693b509

File tree

79 files changed

+1231
-449
lines changed

Some content is hidden

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

79 files changed

+1231
-449
lines changed

docs/ABI/Mangling.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ types where the metadata itself has unknown layout.)
218218
global ::= global 'Tm' // merged function
219219
global ::= entity // some identifiable thing
220220
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
221+
global ::= from-type to-type generic-signature? 'TR' // reabstraction thunk
222+
global ::= impl-function-type 'Tz' // objc-to-swift-async completion handler block implementation
221223
global ::= from-type to-type self-type generic-signature? 'Ty' // reabstraction thunk with dynamic 'Self' capture
222224
global ::= from-type to-type generic-signature? 'Tr' // obsolete mangling for reabstraction thunk
223225
global ::= entity generic-signature? type type* 'TK' // key path getter

docs/SIL.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,27 @@ initialized with the resume value, and that value is then owned by the current
28852885
function. If ``await_async_continuation`` instead resumes to its ``error``
28862886
successor, then the memory remains uninitialized.
28872887

2888+
hop_to_executor
2889+
```````````````
2890+
2891+
::
2892+
2893+
sil-instruction ::= 'hop_to_executor' sil-operand
2894+
2895+
hop_to_executor %0 : $T
2896+
2897+
// $T must conform to the Actor protocol
2898+
2899+
Ensures that all instructions, which need to run on the actor's executor
2900+
actually run on that executor.
2901+
This instruction can only be used inside an ``@async`` function.
2902+
2903+
Checks if the current executor is the one which is bound to the operand actor.
2904+
If not, begins a suspension point and enqueues the continuation to the executor
2905+
which is bound to the operand actor.
2906+
2907+
The operand is a guaranteed operand, i.e. not consumed.
2908+
28882909
dealloc_stack
28892910
`````````````
28902911
::

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ ERROR(error_unable_to_load_supplementary_output_file_map, none,
156156

157157
ERROR(error_missing_entry_in_supplementary_output_file_map, none,
158158
"supplementary output file map '%0' is missing an entry for '%1' "
159-
"(this likely indicates a compiler issue; please file a bug report)",
159+
"(this likely indicates a compiler issue; " SWIFT_BUG_REPORT_MESSAGE ")",
160160
(StringRef, StringRef))
161161

162162
ERROR(error_repl_requires_no_input_files,none,
@@ -307,8 +307,8 @@ ERROR(symbol_in_ir_not_in_tbd,none,
307307
(StringRef, StringRef))
308308

309309
ERROR(tbd_validation_failure,none,
310-
"please file a radar or open a bug on bugs.swift.org with this code, and "
311-
"add -Xfrontend -validate-tbd-against-ir=none to squash the errors", ())
310+
SWIFT_BUG_REPORT_MESSAGE ", and add "
311+
"'-Xfrontend -validate-tbd-against-ir=none' to squash the errors", ())
312312

313313
ERROR(redundant_prefix_compilation_flag,none,
314314
"invalid argument '-D%0'; did you provide a redundant '-D' in your "

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,9 +1568,6 @@ ERROR(attr_specialize_unknown_parameter_name,none,
15681568
ERROR(attr_specialize_expected_bool_value,none,
15691569
"expected a boolean true or false value in '_specialize' attribute", ())
15701570

1571-
WARNING(attr_specialize_export_true_no_op,none,
1572-
"'exported: true' has no effect in '_specialize' attribute", ())
1573-
15741571
ERROR(attr_specialize_missing_parameter_label_or_where_clause,none,
15751572
"expected a parameter label or a where clause in '_specialize' attribute", ())
15761573

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ ERROR(serialization_target_too_new_repl,none,
766766

767767
ERROR(serialization_fatal,Fatal,
768768
"fatal error encountered while reading from module '%0'; "
769-
"please file a bug report with your project and the crash log",
769+
SWIFT_BUG_REPORT_MESSAGE,
770770
(StringRef))
771771
NOTE(serialization_misc_version,none,
772772
"module '%0' full misc version is '%1'",
@@ -2735,6 +2735,7 @@ NOTE(construct_raw_representable_from_unwrapped_value,none,
27352735

27362736
ERROR(decl_from_hidden_module,none,
27372737
"cannot use %0 %1 %select{here|as property wrapper here|"
2738+
"as result builder here|"
27382739
"in an extension with public or '@usableFromInline' members|"
27392740
"in an extension with conditional conformances}2; "
27402741
"%select{%3 has been imported as implementation-only|"
@@ -2743,12 +2744,14 @@ ERROR(decl_from_hidden_module,none,
27432744
(DescriptiveDeclKind, DeclName, unsigned, Identifier, unsigned))
27442745
WARNING(decl_from_hidden_module_warn,none,
27452746
"cannot use %0 %1 %select{in SPI|as property wrapper in SPI|"
2747+
"as result builder in SPI|"
27462748
"in an extension with public or '@usableFromInline' members|"
27472749
"in an extension with conditional conformances}2; "
27482750
"%select{%3 has been imported as implementation-only}4",
27492751
(DescriptiveDeclKind, DeclName, unsigned, Identifier, unsigned))
27502752
ERROR(conformance_from_implementation_only_module,none,
27512753
"cannot use conformance of %0 to %1 %select{here|as property wrapper here|"
2754+
"as result builder here|"
27522755
"in an extension with public or '@usableFromInline' members|"
27532756
"in an extension with conditional conformances}2; "
27542757
"%select{%3 has been imported as implementation-only|"
@@ -3499,7 +3502,7 @@ ERROR(type_of_expression_is_ambiguous,none,
34993502

35003503
ERROR(failed_to_produce_diagnostic,Fatal,
35013504
"failed to produce diagnostic for expression; "
3502-
"please file a bug report", ())
3505+
SWIFT_BUG_REPORT_MESSAGE, ())
35033506

35043507

35053508
ERROR(missing_protocol,none,

include/swift/AST/ForeignAsyncConvention.h

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,51 @@ namespace swift {
2626
class ForeignAsyncConvention {
2727
public:
2828
struct Info {
29+
private:
2930
/// The index of the completion handler parameters.
3031
unsigned CompletionHandlerParamIndex;
3132

3233
/// When non-zero, indicates which parameter to the completion handler is
3334
/// the Error? parameter (minus one) that makes this async function also
3435
/// throwing.
35-
unsigned CompletionHandlerErrorParamIndex;
36-
36+
unsigned CompletionHandlerErrorParamIndexPlusOneOrZero;
37+
38+
public:
3739
Info()
38-
: CompletionHandlerParamIndex(0), CompletionHandlerErrorParamIndex(0) { }
40+
: CompletionHandlerParamIndex(0),
41+
CompletionHandlerErrorParamIndexPlusOneOrZero(0) { }
3942

4043
Info(
4144
unsigned completionHandlerParamIndex,
4245
Optional<unsigned> completionHandlerErrorParamIndex)
4346
: CompletionHandlerParamIndex(completionHandlerParamIndex),
44-
CompletionHandlerErrorParamIndex(
47+
CompletionHandlerErrorParamIndexPlusOneOrZero(
4548
completionHandlerErrorParamIndex
4649
? *completionHandlerErrorParamIndex + 1
4750
: 0) {}
4851

52+
/// Retrieve the index of the completion handler argument in the method's
53+
/// parameter list.
54+
unsigned completionHandlerParamIndex() const {
55+
return CompletionHandlerParamIndex;
56+
}
57+
4958
/// Retrieve the index of the \c Error? parameter in the completion handler's
5059
/// parameter list. When argument passed to this parameter is non-null, the
5160
/// provided error will be thrown by the async function.
5261
Optional<unsigned> completionHandlerErrorParamIndex() const {
53-
if (CompletionHandlerErrorParamIndex == 0)
62+
if (CompletionHandlerErrorParamIndexPlusOneOrZero == 0)
5463
return None;
5564

56-
return CompletionHandlerErrorParamIndex - 1;
65+
return CompletionHandlerErrorParamIndexPlusOneOrZero - 1;
5766
}
5867

5968
/// Whether the async function is throwing due to the completion handler
6069
/// having an \c Error? parameter.
6170
///
6271
/// Equivalent to \c static_cast<bool>(completionHandlerErrorParamIndex()).
6372
bool isThrowing() const {
64-
return CompletionHandlerErrorParamIndex != 0;
73+
return CompletionHandlerErrorParamIndexPlusOneOrZero != 0;
6574
}
6675
};
6776

@@ -88,7 +97,7 @@ class ForeignAsyncConvention {
8897
/// Retrieve the index of the completion handler parameter, which will be
8998
/// erased from the Swift signature of the imported async function.
9099
unsigned completionHandlerParamIndex() const {
91-
return TheInfo.CompletionHandlerParamIndex;
100+
return TheInfo.completionHandlerParamIndex();
92101
}
93102

94103
/// Retrieve the index of the \c Error? parameter in the completion handler's
@@ -108,10 +117,10 @@ class ForeignAsyncConvention {
108117

109118
bool operator==(ForeignAsyncConvention other) const {
110119
return CompletionHandlerType == other.CompletionHandlerType
111-
&& TheInfo.CompletionHandlerParamIndex ==
112-
other.TheInfo.CompletionHandlerParamIndex
113-
&& TheInfo.CompletionHandlerErrorParamIndex ==
114-
other.TheInfo.CompletionHandlerErrorParamIndex;
120+
&& TheInfo.completionHandlerParamIndex()
121+
== other.TheInfo.completionHandlerParamIndex()
122+
&& TheInfo.completionHandlerErrorParamIndex()
123+
== other.TheInfo.completionHandlerErrorParamIndex();
115124
}
116125

117126
bool operator!=(ForeignAsyncConvention other) const {

include/swift/AST/ForeignInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef SWIFT_FOREIGN_INFO_H
2020
#define SWIFT_FOREIGN_INFO_H
2121

22+
#include "swift/AST/ForeignAsyncConvention.h"
2223
#include "swift/AST/ForeignErrorConvention.h"
2324
#include "swift/AST/Decl.h"
2425

@@ -27,6 +28,7 @@ namespace swift {
2728
struct ForeignInfo {
2829
ImportAsMemberStatus Self;
2930
Optional<ForeignErrorConvention> Error;
31+
Optional<ForeignAsyncConvention> Async;
3032
};
3133

3234
} // end namespace swift

include/swift/AST/ModuleLoader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <system_error>
2929

3030
namespace llvm {
31-
class FileCollector;
31+
class FileCollectorBase;
3232
}
3333

3434
namespace clang {
@@ -84,7 +84,7 @@ class DependencyTracker {
8484
public:
8585
explicit DependencyTracker(
8686
IntermoduleDepTrackingMode Mode,
87-
std::shared_ptr<llvm::FileCollector> FileCollector = {});
87+
std::shared_ptr<llvm::FileCollectorBase> FileCollector = {});
8888

8989
/// Adds a file as a dependency.
9090
///

include/swift/Basic/Compiler.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,18 @@
8989
#define SWIFT_ATTRIBUTE_NORETURN
9090
#endif
9191

92+
#ifndef SWIFT_BUG_REPORT_URL
93+
#define SWIFT_BUG_REPORT_URL "https://swift.org/contributing/#reporting-bugs"
94+
#endif
95+
96+
#define SWIFT_BUG_REPORT_MESSAGE_BASE \
97+
"submit a bug report (" SWIFT_BUG_REPORT_URL \
98+
") and include the project"
99+
100+
#define SWIFT_BUG_REPORT_MESSAGE \
101+
"please " SWIFT_BUG_REPORT_MESSAGE_BASE
102+
103+
#define SWIFT_CRASH_BUG_REPORT_MESSAGE \
104+
"Please " SWIFT_BUG_REPORT_MESSAGE_BASE " and the crash backtrace."
105+
92106
#endif // SWIFT_BASIC_COMPILER_H

include/swift/ClangImporter/ClangImporter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace llvm {
2525
class Triple;
26-
class FileCollector;
26+
class FileCollectorBase;
2727
template<typename Fn> class function_ref;
2828
}
2929

@@ -172,9 +172,9 @@ class ClangImporter final : public ClangModuleLoader {
172172

173173
/// Create a new clang::DependencyCollector customized to
174174
/// ClangImporter's specific uses.
175-
static std::shared_ptr<clang::DependencyCollector>
176-
createDependencyCollector(IntermoduleDepTrackingMode Mode,
177-
std::shared_ptr<llvm::FileCollector> FileCollector);
175+
static std::shared_ptr<clang::DependencyCollector> createDependencyCollector(
176+
IntermoduleDepTrackingMode Mode,
177+
std::shared_ptr<llvm::FileCollectorBase> FileCollector);
178178

179179
/// Append visible module names to \p names. Note that names are possibly
180180
/// duplicated, and not guaranteed to be ordered in any way.

include/swift/Demangling/DemangleNodes.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ CONTEXT_NODE(NativePinningMutableAddressor)
159159
NODE(NominalTypeDescriptor)
160160
NODE(NonObjCAttribute)
161161
NODE(Number)
162+
NODE(ObjCAsyncCompletionHandlerImpl)
162163
NODE(ObjCAttribute)
163164
NODE(ObjCBlock)
164165
NODE(EscapingObjCBlock)

0 commit comments

Comments
 (0)