Skip to content

Commit 15462e0

Browse files
authored
Merge pull request #1012 from swiftwasm/swift/release/5.4
[pull] swiftwasm-release/5.4 from swift/release/5.4
2 parents f447765 + 414a77d commit 15462e0

Some content is hidden

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

45 files changed

+550
-18
lines changed

clang/include/clang/AST/Attr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class ParameterABIAttr : public InheritableParamAttr {
194194
switch (getKind()) {
195195
case attr::SwiftContext:
196196
return ParameterABI::SwiftContext;
197+
case attr::SwiftAsyncContext:
198+
return ParameterABI::SwiftAsyncContext;
197199
case attr::SwiftErrorResult:
198200
return ParameterABI::SwiftErrorResult;
199201
case attr::SwiftIndirectResult:

clang/include/clang/Basic/Attr.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,6 +2332,11 @@ def SwiftContext : ParameterABIAttr {
23322332
let Documentation = [SwiftContextDocs];
23332333
}
23342334

2335+
def SwiftAsyncContext : ParameterABIAttr {
2336+
let Spellings = [Clang<"swift_async_context">];
2337+
let Documentation = [SwiftAsyncContextDocs];
2338+
}
2339+
23352340
def SwiftErrorResult : ParameterABIAttr {
23362341
let Spellings = [Clang<"swift_error_result">];
23372342
let Documentation = [SwiftErrorResultDocs];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,6 +4092,19 @@ A context parameter must have pointer or reference type.
40924092
}];
40934093
}
40944094

4095+
def SwiftAsyncContextDocs : Documentation {
4096+
let Category = DocCatVariable;
4097+
let Content = [{
4098+
The ``swift_async_context`` attribute marks a parameter as having the
4099+
special asynchronous context-parameter ABI treatment.
4100+
4101+
This treatment generally passes the context value in a special register
4102+
which is normally callee-preserved.
4103+
4104+
A context parameter must have pointer or reference type.
4105+
}];
4106+
}
4107+
40954108
def SwiftErrorResultDocs : Documentation {
40964109
let Category = DocCatVariable;
40974110
let Content = [{

clang/include/clang/Basic/Specifiers.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ namespace clang {
361361
/// This parameter (which must have pointer type) uses the special
362362
/// Swift context-pointer ABI treatment. There can be at
363363
/// most one parameter on a given function that uses this treatment.
364-
SwiftContext
364+
SwiftContext,
365+
366+
/// This parameter (which must have pointer type) uses the special
367+
/// Swift asynchronous context-pointer ABI treatment. There can be at
368+
/// most one parameter on a given function that uses this treatment.
369+
SwiftAsyncContext,
365370
};
366371

367372
/// Assigned inheritance model for a class in the MS C++ ABI. Must match order

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,6 +2912,7 @@ CXXNameMangler::mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo PI) {
29122912

29132913
// All of these start with "swift", so they come before "ns_consumed".
29142914
case ParameterABI::SwiftContext:
2915+
case ParameterABI::SwiftAsyncContext:
29152916
case ParameterABI::SwiftErrorResult:
29162917
case ParameterABI::SwiftIndirectResult:
29172918
mangleVendorQualifier(getParameterABISpelling(PI.getABI()));

clang/lib/AST/TypePrinter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ StringRef clang::getParameterABISpelling(ParameterABI ABI) {
807807
llvm_unreachable("asking for spelling of ordinary parameter ABI");
808808
case ParameterABI::SwiftContext:
809809
return "swift_context";
810+
case ParameterABI::SwiftAsyncContext:
811+
return "swift_async_context";
810812
case ParameterABI::SwiftErrorResult:
811813
return "swift_error_result";
812814
case ParameterABI::SwiftIndirectResult:

clang/lib/CodeGen/CGCall.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,10 @@ void CodeGenModule::ConstructAttributeList(
22832283
case ParameterABI::SwiftContext:
22842284
Attrs.addAttribute(llvm::Attribute::SwiftSelf);
22852285
break;
2286+
2287+
case ParameterABI::SwiftAsyncContext:
2288+
Attrs.addAttribute(llvm::Attribute::SwiftAsync);
2289+
break;
22862290
}
22872291

22882292
if (FI.getExtParameterInfo(ArgNo).isNoEscape())

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,6 +4795,14 @@ void Sema::AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI,
47954795
D->addAttr(::new (Context) SwiftContextAttr(Context, CI));
47964796
return;
47974797

4798+
case ParameterABI::SwiftAsyncContext:
4799+
if (!isValidSwiftContextType(type)) {
4800+
Diag(CI.getLoc(), diag::err_swift_abi_parameter_wrong_type)
4801+
<< getParameterABISpelling(abi) << /*pointer to pointer */ 0 << type;
4802+
}
4803+
D->addAttr(::new (Context) SwiftAsyncContextAttr(Context, CI));
4804+
return;
4805+
47984806
case ParameterABI::SwiftErrorResult:
47994807
if (!isValidSwiftErrorResultType(type)) {
48004808
Diag(CI.getLoc(), diag::err_swift_abi_parameter_wrong_type)
@@ -7838,6 +7846,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
78387846
case ParsedAttr::AT_SwiftContext:
78397847
S.AddParameterABIAttr(D, AL, ParameterABI::SwiftContext);
78407848
break;
7849+
case ParsedAttr::AT_SwiftAsyncContext:
7850+
S.AddParameterABIAttr(D, AL, ParameterABI::SwiftAsyncContext);
7851+
break;
78417852
case ParsedAttr::AT_SwiftErrorResult:
78427853
S.AddParameterABIAttr(D, AL, ParameterABI::SwiftErrorResult);
78437854
break;

clang/lib/Sema/SemaType.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,10 @@ static void checkExtParameterInfos(Sema &S, ArrayRef<QualType> paramTypes,
27162716
checkForSwiftCC(paramIndex);
27172717
continue;
27182718

2719+
case ParameterABI::SwiftAsyncContext:
2720+
// FIXME: might want to require swiftasynccc when it exists
2721+
continue;
2722+
27192723
// swift_error parameters must be preceded by a swift_context parameter.
27202724
case ParameterABI::SwiftErrorResult:
27212725
checkForSwiftCC(paramIndex);

clang/test/CodeGen/arm-swiftcall.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define OUT __attribute__((swift_indirect_result))
77
#define ERROR __attribute__((swift_error_result))
88
#define CONTEXT __attribute__((swift_context))
9+
#define ASYNC_CONTEXT __attribute__((swift_async_context))
910

1011
/*****************************************************************************/
1112
/****************************** PARAMETER ABIS *******************************/
@@ -53,6 +54,9 @@ void test_context_error_1() {
5354
SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {}
5455
// CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, i32* swiftself{{.*}}, float** swifterror %0)
5556

57+
SWIFTCALL void async_context_1(ASYNC_CONTEXT void *self) {}
58+
// CHECK-LABEL: define {{.*}} void @async_context_1(i8* swiftasync
59+
5660
/*****************************************************************************/
5761
/********************************** LOWERING *********************************/
5862
/*****************************************************************************/

0 commit comments

Comments
 (0)